I bet you are double-escaping it. Try without the AddSlashes() call. By default PHP will escape this for you automatically.
-Rasmus On Thu, 20 Jun 2002, David McInnis wrote: > After posting this on the MySQL list and getting some feedback we were > able to determine that this was not a flaw with MySQL. Any ideas from > the PHP community? > > ======= > > Can anyone tell me why this does not work? I am using php and mysql. > > When I do an insert from select into a mysql table I get an error > whenever a value from the select portion of the query contains an > apostrophe. Before I insert the initial value I use the php > addslashes() function to escape the ' and " characters. > > For example: > > If clients table contans a field called fname and it has a value of > "O'Henry". Remembering that I have used addslashes() before inserting > the value into mysql in the first place. > > The following query will fail on insert: > > Sql = "insert into orders (fname) SELECT fname from clients where > clientid = '$clientid'"; > > > David McInnis > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php