i am trying to figure out how to strip unwanted characters so that my db queries (inserts and selects) won't get messed up and information will show up properly in my forms.
i have forms on the site i am developing. these forms enter data into the db and also get populated by data from the db. i need a way to provide data integrity.
originally, when something like:
"fred's house"
is submitted by a form, it is saved in the db as fred\'s house. then on an "update" form, the information would be shown as fred\'s house (i think).
so now i use this function on all my POST variables:
$release_date = anti_slash($_POST['release_date']);
function anti_slash($strValue) {
if ($strValue != "") {
$strValue = stripslashes($strValue);
$strValue = str_replace("\"", "", $strValue); }
return $strValue;
}
this doesn't work though, my query now includes the ' in fred's house and the query doesn't have the ' escaped.
what is a fullproof method for dealing with " and ' characters or any others that can mess up your queries?
I have MySQL 4.0.14, Apache/1.3.28 (Unix) mod_throttle/3.1.2 PHP/4.3.4RC1 mod_ssl/2.8.15 OpenSSL/0.9.7a on FreeBSD.
I am also going to need it to work on another server with MySQL 3.23.51, Apache/1.3.26 (Unix) PHP/4.3.4 on Solaris 8.
chris