mike12255 Posted February 16, 2009 Share Posted February 16, 2009 I have the following line: <?php $query = "SELECT * FROM `phpforum_tutorial` WHERE `postid` = $id AND WHERE `area` = math"; ?> I dont recive an error from the query but i tried importing it into phpmyadmin and nothing came up, well an error did so i know i did the query wrong, anyone know my mistake? Link to comment https://forums.phpfreaks.com/topic/145472-solved-php-mysql-query-not-working/ Share on other sites More sharing options...
allworknoplay Posted February 16, 2009 Share Posted February 16, 2009 bad query...use this: <?php $query = "SELECT * FROM `phpforum_tutorial` WHERE `postid` = $id AND `area` = math"; ?> Link to comment https://forums.phpfreaks.com/topic/145472-solved-php-mysql-query-not-working/#findComment-763719 Share on other sites More sharing options...
genericnumber1 Posted February 16, 2009 Share Posted February 16, 2009 SELECT * FROM `phpforum_tutorial` WHERE `postid` = $id AND `area` = 'math' You need quotes around math if you don't want it to think it's a non-string, and you only need to say WHERE once. Link to comment https://forums.phpfreaks.com/topic/145472-solved-php-mysql-query-not-working/#findComment-763721 Share on other sites More sharing options...
mike12255 Posted February 16, 2009 Author Share Posted February 16, 2009 ok, it worked, thanks mates. Wasnt sure about the second WHERE and had no idea about the quotes Link to comment https://forums.phpfreaks.com/topic/145472-solved-php-mysql-query-not-working/#findComment-763731 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.