Further to my last post, I added this to santize. I also created a new mysql user with access to only findmefollow portion of the asterisk table for limited access and assigned only two simultaneous connections with only 10 changes queries per hour (as I know that no more queries will be put through probably)<div>

<br></div><div>if ($npaa&gt;=200 &amp;&amp; $nxxa&gt;=200 &amp;&amp; $npaa!=900 &amp;&amp; $npaa!=911)</div><div><br></div><div>Should that suffice against SQL injections? The if condition changes the string to number so it removes the chance of people adding other characters and it also sticks to format NPANXXXX or 2XX2XXXX.</div>

<div><br></div><div>Thanks<br><br><div class="gmail_quote">On Sat, Jul 10, 2010 at 10:21 AM, bruce bruce <span dir="ltr">&lt;<a href="mailto:bruceb444@gmail.com">bruceb444@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

Thank you for the amazing reply. First few lines of your e-mail was EXACTLY getting me to where I made a mistake. I guess I didn&#39;t take the () and &#39; &#39; at their face value and was looking somewhere else for the problem.<div>


<br></div><div>For sanatizing you mean checking the numbers to make sure they are valid numbers and not alphabet or other charecters? or, are you pointing the fact that I am keeping mysql root password in plain .php file? I have done an include of a php file which has mysql root password and that is insert as an #incldue in the html file. So, if someone checks source for html can&#39;t see mysql root password. Even though root is user on mysql is to accept only from localhost.</div>


<div><br></div><div>I would really appreciate it if you can weigh in on it a bit.</div><div><br></div><div>Thanks,</div><div>Bruce<div><div></div><div class="h5"><br><br><div class="gmail_quote">On Sat, Jul 10, 2010 at 7:42 AM, Gerald A <span dir="ltr">&lt;<a href="mailto:geraldablists@gmail.com" target="_blank">geraldablists@gmail.com</a>&gt;</span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Bruce,<br><br>First, your problem isn&#39;t PHP, it seems to be SQL and I&#39;m guessing MySQL at that.<br><div style="display:inline">


</div><br>
Next, you seem to be accepting user input and not sanatizing it. DANGER WILL ROBINSON!!!<br>This is bad, because it leaves you open to something known as a &quot;SQL injection attack&quot;.<br><br>Now, as to syntax:<br><br>



<div class="gmail_quote"><div>On Sat, Jul 10, 2010 at 12:07 AM, bruce bruce <span dir="ltr">&lt;<a href="mailto:bruceb444@gmail.com" target="_blank">bruceb444@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">



<br><div>I am making another module for Voicemail. I have three fields in a POST form that have to be connected together to make it a single 10 digit number but there is something wrong in my syntax probably.</div>

<div><br></div><div><br></div><div><div>$npaa = &quot;(&#39;$_POST[anpa]&#39;)&quot;;</div><div>$nxxa = &quot;(&#39;$_POST[anxx]&#39;)&quot;;</div><div>$blocka = &quot;(&#39;$_POST[ablock]&#39;)&quot;;</div><div><br></div>





<div><b>$grplist = $npaa.$nxxa.$blocka;</b></div></div></blockquote></div><div><br>Ok, so suppose arpa=111, anxx=222 and ablock=3333.<br>grplist would then be (&#39;111&#39;)(&#39;333&#39;)(&#39;4444&#39;). <br><br></div>


<div><blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">
<div>$sql=&quot;INSERT INTO findmefollow(grpnum, strategy, grptime, grppre, grplist, annmsg_id, postdest, dring, needsconf, remotealert_id, toolate_id, ringing, pre_ring) VALUES (&#39;$_POST[grpnum]&#39;,&#39;ringall&#39;,&#39;$_POST[grptime]&#39;,&#39;$_POST[grppre]&#39;,$grplist,&#39;0&#39;,&#39;$_POST[postdest]&#39;,&#39;&#39;,&#39;&#39;,&#39;0&#39;,&#39;0&#39;,&#39;Ring&#39;,&#39;$_POST[pre_ring]&#39;)&quot;;</div>



<div>

</div><div><br></div><div><br></div><div>It seems that $grplist is the problem. Can someone please point what is wrong?</div><div><br></div><div>Error:</div><div><span style="font-family:&#39;Times New Roman&#39;;font-size:medium">Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near &#39;(&#39;333&#39;)(&#39;4444&#39;),&#39;0&#39;,&#39;ext-local,vmb2000,1&#39;,&#39;&#39;,&#39;&#39;,&#39;0&#39;,&#39;0&#39;,&#39;Ring&#39;,&#39;0&#39;)&#39; at line 3</span></div>



</blockquote></div><div><br>Look closesly, grasshopper. See it? (Does the hint above help?) Hmmm, ok.<br><br>Let&#39;s write the line as SQL:<br>INSERT INTO findmefollow(grpnum, strategy, grptime, grppre, grplist,
annmsg_id, postdest, dring, needsconf, remotealert_id, toolate_id,
ringing, pre_ring) VALUES (&#39;0&#39;,&#39;ringall&#39;,&#39;0&#39;,&#39;0&#39;,(&#39;111&#39;)(&#39;333&#39;)(&#39;4444&#39;),&#39;0&#39;,&#39;0&#39;,&#39;&#39;,&#39;&#39;,&#39;0&#39;,&#39;0&#39;,&#39;Ring&#39;,&#39;0&#39;)&quot;;<br>



<br>Clear now? You are trying to insert the raw value --&gt; (&#39;111&#39;)(&#39;333&#39;)(&#39;4444&#39;) &lt;-- into your database. This can&#39;t make any sense except as string, And this isn&#39;t one.<br><br>I think what you might have meant is to quote the _whole thing_ as a string, and not the individual pieces. Then:<br>



$grplist = &quot;&#39;(&quot;.$npaa.$nxxa.$blocka.&quot;)&#39;&quot;;<br>and <br>$blocka = &quot;($_POST[ablock])&quot;;  # and for all of them above<br><br>This would make the value &#39;(111)(333)(4444)&#39;, which should work fine.<br>



<br>Now, if you really meant to add in the quotes, you&#39;ll have to &quot;quote the quotes&quot;, which can be hard to do in good times.<br><br>Hope this helps,<br>Gerald.<br></div></div>
</blockquote></div><br></div></div></div>
</blockquote></div><br></div>