hellonoko Posted April 1, 2009 Share Posted April 1, 2009 My script inserts crawled links from a age into my DB. <?php if (mysql_num_rows(mysql_query("SELECT * FROM `secondarylinks` WHERE link = '".mysql_real_escape_string($link)."' LIMIT 1")) == 0) { $query = "INSERT INTO `secondarylinks` ( `link` , `scraped` , `host` ) VALUES ( '".mysql_real_escape_string($link)."'' , '0' , '$site')"; $result = mysql_query($query) or die (mysql_error()); } ?> However I am receiving the following 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 '0' , 'empreintes-digitales.fr')' at line 1 When it tries to insert this url: ?tags=valerie je t'aime Is there something I should do besides mysql_real_escape_string() Before using mysql_real_escape_string() my script would return the URL as aime Any ideas? Link to comment https://forums.phpfreaks.com/topic/152014-solved-mysql-error-with-inserting-url-into-db/ Share on other sites More sharing options...
sdi126 Posted April 1, 2009 Share Posted April 1, 2009 It looks like you have an extra single quote after the $link variable...you have double single quotes which is not what you want...you just need one. Link to comment https://forums.phpfreaks.com/topic/152014-solved-mysql-error-with-inserting-url-into-db/#findComment-798334 Share on other sites More sharing options...
hellonoko Posted April 1, 2009 Author Share Posted April 1, 2009 Thanks! That fixed it... Link to comment https://forums.phpfreaks.com/topic/152014-solved-mysql-error-with-inserting-url-into-db/#findComment-798340 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.