Drezard Posted March 26, 2010 Share Posted March 26, 2010 I'm writing a bit of code that uses this query: "SELECT * FROM articles WHERE link='".$link."'" When I execute this in the mysql console such as : SELECT * FROM articles WHERE link='http://www.theage.com.au/travel/travel-news/nerd-bird-flies-like-a-brick-20100326-r0eh.html; It works perfectly. Displays the results I want... But when I try and do the same query with PHP I get : 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://www.theage.com.au/travel/travel-news/nerd-bird-flies-like-a-brick-201003' at line 1 Ideas anyone? I'm guessing its formatting? Daniel Link to comment https://forums.phpfreaks.com/topic/196558-using-links-and-mysql/ Share on other sites More sharing options...
o3d Posted March 26, 2010 Share Posted March 26, 2010 SELECT * FROM articles WHERE link='http://www.theage.com.au/travel/travel-news/nerd-bird-flies-like-a-brick-20100326-r0eh.html'; You forgot to close the string with a single quote. Link to comment https://forums.phpfreaks.com/topic/196558-using-links-and-mysql/#findComment-1032005 Share on other sites More sharing options...
georgebates Posted March 26, 2010 Share Posted March 26, 2010 If this code works to get the results you want . . . SELECT * FROM articles WHERE link='http://www.theage.com.au/travel/travel-news/nerd-bird-flies-like-a-brick-20100326-r0eh.html'; . . .why not just use that on your php site? Link to comment https://forums.phpfreaks.com/topic/196558-using-links-and-mysql/#findComment-1032085 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.