how to process php vars before trying to execute query? e.g. i am trying to insert text with ",' but it query couldn't execute? what is the best way to solve this with PDO class?
many thanks
how to process php vars before trying to execute query? e.g. i am trying to insert text with ",' but it query couldn't execute? what is the best way to solve this with PDO class?
many thanks
Take a look at both addslashes() and mysql_real_escape_string(). What's happening here is that a ' is a special character, meaning MySQL will treat it as part of it's syntax, instead of treating it as a string like you want. addslashes or mysql_real_escape_string will add a backslash \ before all single and double quotes (and others) to make them not part of the MySQL syntax.
You can use mysql_real_escape_string($string) to escape your incoming string so that ' and " will be escaped.