Jump to content

Error


jj20051

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.