View Single Post
  #11  
Old 09-20-2007, 12:10 PM
Theeper
Discordant
 
Join Date: May 2004
Posts: 290
Default

This can be confusing sometimes if magic_quotes_gpc are enabled in PHP. This setting automagically escapes single and double quotes on POSTed data, but doesn't actually insert the escape characters into the DB. So, the data will post properly, but will need escaped when echoing into the form HTML.

On the other hand, if magic_quotes_gpc is off on your system, the single quotes might be breaking your insert query string, so the data isn't making it to the DB properly.

Either way, using double quotes to delimit your string values in the HTML form is an easy way to deal with single quotes. This is, of course if you don't plan on ever having strings that have double quotes in them. If you do, you could always do some str_replace()'s with ascii values for quotes.
Reply With Quote