jj20051 Posted November 2, 2008 Share Posted November 2, 2008 Ok I Wrote This Script To Copy Data From One Table To Another... I Recognize The URL At The End From Being In The oDescription Variable. I Get This 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 'http://trientanetwork.directtrack.com/z/407/CD643/"> Here Is The Code: $db->query( 'INSERT INTO completedoffers (uID, coTitle, coPrice, coSite, coDescription) VALUES("' . $data[0]["uID"] . '", "' . $data[0]["oTitle"] . '", "' . $data[0]["oPrice"] . '", "' . $data[0]["oSite"] . '", "' . $data[0]["oDescription"] . '")'); Link to comment https://forums.phpfreaks.com/topic/131083-error/ Share on other sites More sharing options...
thebadbad Posted November 2, 2008 Share Posted November 2, 2008 Looks like the URL has "> at the end, which is messing with the query where you use double quotes. Link to comment https://forums.phpfreaks.com/topic/131083-error/#findComment-680574 Share on other sites More sharing options...
jj20051 Posted November 2, 2008 Author Share Posted November 2, 2008 The Code Is A Banner URL Link to comment https://forums.phpfreaks.com/topic/131083-error/#findComment-680575 Share on other sites More sharing options...
jj20051 Posted November 2, 2008 Author Share Posted November 2, 2008 So How would I Make It Accept Whatever Is Put In? Link to comment https://forums.phpfreaks.com/topic/131083-error/#findComment-680578 Share on other sites More sharing options...
thebadbad Posted November 2, 2008 Share Posted November 2, 2008 Use mysql_real_escape_string() on any input to be used in a query. And I would use single quotes in the SQL, much easier when dealing with variables too: <?php //run variables through mysql_real_escape_string() here $db->query("INSERT INTO completedoffers (uID, coTitle, coPrice, coSite, coDescription) VALUES('{$data[0]['uID']}', '{$data[0]['oTitle']}', '{$data[0]['oPrice']}', '{$data[0]['oSite']}', '{$data[0]['oDescription']}')"); ?> Link to comment https://forums.phpfreaks.com/topic/131083-error/#findComment-680582 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.