dealiong with quote's in SQL strings

From: Date: Fri, 13 Jun 2003 13:43:49 +0000
Subject: dealiong with quote's in SQL strings
Groups: php.general 
Request: Send a blank email to php-general+get-151357@lists.php.net to get a copy of this message
Hi List I recently installed 4.3.1 and enabled the magic_quotes_gpc to deal with quotes in mysql inserts. However, I think I have run into a problem that might be related, and was wondering if there is an easy way to fix it: I have a script that gets user input from a drop-down, on the action page I search a mysql table for the row matching the selection made previously. What I do then is to extract the result of that "select * from table where data = form_selection" and then to re-insert the data into the table ; note, re-insert, NOT UPDATE ( the app cals for a new row to be added with the updated data, so the "old" row stays intact and a new row is added that contains some of the old row's data plus some new stuff I add). So, the new insert sql looks as per usual insert into table (var1,var2,var3,var4,...) values ('$var1','$var2',....); where $var1, $var2 etc is either "inherited" from the extract of the first querie's result set, or overwritten with my newly generated values. The problem now comes in with this: If one or more of the extracted variables containes something like " O'Healy " or something similar that causes trouble with the quotes in the new INSERT sql, well, you see the problem... And I don't want to have to go and addslashes to all my extracted variables, because there really are a whole heap of them. So, is there another php.ini setting that I'm missing to help me with this, or maybe a function that will addslashes to all my extracted vars? I'm lazy, shoot me!

« previous php.general (#151357) next »