oskare100 Posted January 24, 2007 Share Posted January 24, 2007 Hello,When I run this code:[code=php:0]$sql55="INSERT INTO users (username, password, ebay_username, ebay_status, ebay_email, paypal_status, paypal_email, num_purchases, first_name, last_name, address_street, address_city, address_state, address_zip, address_country, address_status, created) VALUES('".$row->account_username."', '".$row->account_password."', '".$row->auction_buyer_id."', '$ebay_status', '".$row->account_email."', '".$row->payer_status."', '".$row->account_email."', 1, '".$row->first_name."', '".$row->last_name."', '".$row->address_street."', '".$row->address_city."', '".$row->address_state."', '".$row->address_zip."', '".$row->address_country."', '".$row->address_status."', '$new_script_received')"; $result55 = mysql_query($sql55) or die( mysql_error() );[/code]I get the error "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'S ROAD',"Now it seams like the problem is this field "51 ST SIMONS'S ROAD" and I think the problem is the ', correct me if I'm wrong. How can I solve this problem? (It is a lot of rows I'm running this querey on so I can't just insert it manually).Thanks in advance,Best RegardsOskar R Link to comment https://forums.phpfreaks.com/topic/35490-how-to-insert-things-into-a-mysql-database-with-an-in/ Share on other sites More sharing options...
bqallover Posted January 24, 2007 Share Posted January 24, 2007 There are a few ways to fix this. One way is to run addslashes on each variable you pass to the query...[code]addslashes( $row->address_street )[/code]Then run stripslashes on them when you retrieve them Link to comment https://forums.phpfreaks.com/topic/35490-how-to-insert-things-into-a-mysql-database-with-an-in/#findComment-167919 Share on other sites More sharing options...
HuggieBear Posted January 24, 2007 Share Posted January 24, 2007 I'd go with [url=http://uk.php.net/manual/en/function.mysql-real-escape-string.php]mysql_real_escape_string()[/url].RegardsHuggie Link to comment https://forums.phpfreaks.com/topic/35490-how-to-insert-things-into-a-mysql-database-with-an-in/#findComment-167948 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.