Phpfr3ak Posted December 7, 2011 Share Posted December 7, 2011 Can anyone explain to me why this isn't working , and explain how i would rectify the problem, Many Thanks. <? $rawr = mysql_real_escape_string($_GET['type']); "SELECT COUNT(id) FROM items Where type = $rawr" ?> Quote Link to comment https://forums.phpfreaks.com/topic/252689-can-you-explain-why-this-wont-work-please/ Share on other sites More sharing options...
loki951510 Posted December 7, 2011 Share Posted December 7, 2011 shouldnt it be like this? <? $rawr = mysql_real_escape_string($_GET['type']); "SELECT COUNT(id) FROM items Where type = $rawr"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/252689-can-you-explain-why-this-wont-work-please/#findComment-1295383 Share on other sites More sharing options...
Pikachu2000 Posted December 7, 2011 Share Posted December 7, 2011 Don't use short <? tags. Use the full <?php tag syntax. Anyhow, you've stuck a bare string in there after the assignment of the value to $rawr. Did you mean to assign it to a variable as well? Quote Link to comment https://forums.phpfreaks.com/topic/252689-can-you-explain-why-this-wont-work-please/#findComment-1295388 Share on other sites More sharing options...
Phpfr3ak Posted December 7, 2011 Author Share Posted December 7, 2011 Yea, i meant to set it to a variable also, sorry i'm not that great in php can you explain how thats not set as a variable? :/ Quote Link to comment https://forums.phpfreaks.com/topic/252689-can-you-explain-why-this-wont-work-please/#findComment-1295396 Share on other sites More sharing options...
Pikachu2000 Posted December 7, 2011 Share Posted December 7, 2011 If it's in quotes, it's a string. If it isn't preceded by an assignment operator, it's just out there in the middle of nowhere. Put each line of code on its own line, and it will become obvious what the problem is. <?php $rawr = mysql_real_escape_string($_GET['type']); "SELECT COUNT(id) FROM items Where type = $rawr" // <--- No variable assignment, and missing line termination ; here ?> Quote Link to comment https://forums.phpfreaks.com/topic/252689-can-you-explain-why-this-wont-work-please/#findComment-1295406 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.