RE: [PHP] handling ' with mysql/php insert and select

From: Date: Thu, 03 Jan 2008 20:44:18 +0000
Subject: RE: [PHP] handling ' with mysql/php insert and select
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-266586@lists.php.net to get a copy of this message
lots of ways to handle this use HTMLentities($string) to convert the apostrophes use addslashes($string) to escape them use mysql_real_escape_string($string) to escape them the last is my preferred method bastien> Date: Thu, 3 Jan 2008 13:22:09 -0600> From: awilliam@mdah.state.ms..us> To: bastien> php-general@lists.php.net> Subject: [PHP] handling ' with mysql/php insert and select> bastien> > In my form, I am parsing all the text inputs through > mysql_real_escape_string() before bastien> inserting the data. however, when I > look at the SQL query in PHP, when I type the word bastien> blah's to my text box > variable, and then insert it into mysql after being ran through > bastien> mysql_real_escape_string(), it does:> > insert into contract (contract_id, responsibility) bastien> VALUES (15, 'blah\\\'s')> > and when I query the in mysql/PHP it shows:> bastien> > select responsibility from contract where contract_id = 15;> +----------------+> | bastien> responsibility |> +----------------+> | blah\'s |> +----------------+> 1 row in set bastien> (0.00 sec)> > and when I run that select statement in PHP it prints blah\'s on the > bastien> screen. I want it to print back blah's without the \. So what are my > options? run every bastien> variable through stripslashes(); before printing > them to the screen?> > -- > PHP bastien> General Mailing List (http://www.php.net/)> To unsubscribe, visit: bastien> http://www.php.net/unsub..php> _________________________________________________________________ Read what Santa`s been up to! For all the latest, visit asksantaclaus.spaces.live.com! http://asksantaclaus.spaces.live.com/

« previous php.general (#266586) next »