unemployment Posted January 1, 2011 Share Posted January 1, 2011 This query fails. $blogQ = "SELECT `id`, `userid`, `posttitle`, `postdate` AS `posttimestamp`, DATE_FORMAT(`postdate`,'%D \of %M %Y %h:%i%p') AS `postdate`, `postcontent`, `postimage`, `posttags` FROM `blog` WHERE `id`='$_get['id']' or die(mysql_error())"; Error Message: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/www-data/mysite.com/blogpost.php on line 6 Quote Link to comment https://forums.phpfreaks.com/topic/223163-get-error/ Share on other sites More sharing options...
Pikachu2000 Posted January 1, 2011 Share Posted January 1, 2011 . . . WHERE `id`='{$_GET['id']}' or die( . . . (Variable are case-sensitive, BTW.) Quote Link to comment https://forums.phpfreaks.com/topic/223163-get-error/#findComment-1153667 Share on other sites More sharing options...
unemployment Posted January 1, 2011 Author Share Posted January 1, 2011 I tried this and it still doesn't work $blogQ = "SELECT `id`, `userid`, `posttitle`, `postdate` AS `posttimestamp`, DATE_FORMAT(`postdate`,'%D \of %M %Y %h:%i%p') AS `postdate`, `postcontent`, `postimage`, `posttags` FROM `blog` WHERE `id`='{$_get['id']}'" mysql_query($q) or die(); Error changes to... Parse error: syntax error, unexpected T_STRING in /home/www-data/mysite.com/blogpost.php on line 6 Quote Link to comment https://forums.phpfreaks.com/topic/223163-get-error/#findComment-1153669 Share on other sites More sharing options...
PFMaBiSmAd Posted January 1, 2011 Share Posted January 1, 2011 And the double-quote should be at the end of the query string, not after the or die() statement. Actually, the or die() shouldn't even be part of that statement because you are assigning a string to $blogQ Quote Link to comment https://forums.phpfreaks.com/topic/223163-get-error/#findComment-1153670 Share on other sites More sharing options...
Pikachu2000 Posted January 1, 2011 Share Posted January 1, 2011 Wow. That one got right by me, LOL. Quote Link to comment https://forums.phpfreaks.com/topic/223163-get-error/#findComment-1153672 Share on other sites More sharing options...
unemployment Posted January 2, 2011 Author Share Posted January 2, 2011 Ok well you guys have helped, but I still receive this error now... Notice: Undefined variable: _get in /home/www-data/mysite.com/blogpost.php on line 6 Is the get undefined? please explain Quote Link to comment https://forums.phpfreaks.com/topic/223163-get-error/#findComment-1153674 Share on other sites More sharing options...
BLaZuRE Posted January 2, 2011 Share Posted January 2, 2011 Also, something to remember about using single and double quotes that may confuse some people. When including a variable in double quotes, i.e. echo "Hello $name[key]"; , no quotes around key. However, if you use single quotes or no quotes: echo 'Hello' . $name['key']; or echo $name['key']; Quote Link to comment https://forums.phpfreaks.com/topic/223163-get-error/#findComment-1153675 Share on other sites More sharing options...
Pikachu2000 Posted January 2, 2011 Share Posted January 2, 2011 Unless you've defined a $_get array somewhere, it'll be $_GET, not $_get. Variables are case-sensitive. Quote Link to comment https://forums.phpfreaks.com/topic/223163-get-error/#findComment-1153679 Share on other sites More sharing options...
ManiacDan Posted January 22, 2011 Share Posted January 22, 2011 I've edited all your posts to remove the references to your site. Definitely listen to Pika (since he's mentioned it twice). $_get is not a variable, $_GET is. -Dan Quote Link to comment https://forums.phpfreaks.com/topic/223163-get-error/#findComment-1163694 Share on other sites More sharing options...
unemployment Posted January 22, 2011 Author Share Posted January 22, 2011 Thank you so much. I will listen to pika... he seems to know his stuff Quote Link to comment https://forums.phpfreaks.com/topic/223163-get-error/#findComment-1163700 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.