Mysql Insert from select problem with php

From: Date: Fri, 21 Jun 2002 05:56:39 +0000
Subject: Mysql Insert from select problem with php
Groups: php.general 
Request: Send a blank email to php-general+get-103234@lists.php.net to get a copy of this message
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

« previous php.general (#103234) next »