Ok..
My form is as follows:
printf ("<form name=\"chatform\" method=\"get\" action=\"$PHP_SELF\">");
printf ("<input type=\"text\" size=\"50\" maxlength=\"140\" name=\"message_formvar\">");
printf ("<input type=\"submit\" name=\"submit_formvar\" value=\"Send Message\">");
printf("</form>");
In the same page I have:
if ((($submit_formvar) || ($message_formvar)) && ($message_formvar!=""))
.... I have a onliners queue that holds 20 rows. So when someone submits a oneliner, this if-then statement also reads the entire queue into a temporary array, appends the new one liner, and then goes through the entire array, one row at a time, and executes this:
$sql="INSERT INTO oneliners VALUES ('$message_formvar','$ses_uid')"; <--to be referenced as command 1 later on
$ses_uid is a session variable containing an integer representing the username.
Then I have another page display all the one liners simply by "SELECT oneliner FROM oneliners" and I go through the queue printing each row one at a time. Now, I have the display page autorefresh every 20 seconds so it displays a current list.
All standard characters are handled fine but the funky stuff breaks my code. If I have a one liner that is a single apostrophe, then everything is fine. However, the next one liner that is submitted causes my command 1 to give me SQL error number 1064 with the error mesage: You have an error in your SQL syntax near '''')' at line 1
I'm sure it is just because I am not formatting the text properly between PHP and MySQL but I cant figure out where to start. All the functions I tried haven't quite worked.