onthespot Posted July 12, 2009 Share Posted July 12, 2009 Can anyone understand this problem? I am calling from a table in my database which works fine when I don't include a WHERE. However when I do, i get nothing back. The php: <?php function show_league_image($type) { $images = array ( 'league1' => 'first.jpg', 'league2' => 'second.jpg', 'league3' => 'third.jpg' ); if(array_key_exists($type, $images)) return '<img src="images/awards/'.$images[$type].'" width="16" height="36" />'; return false; } $res=mysql_query("SELECT * FROM ".TBL_AWARDS." WHERE awarduser = '$awarduser2' ORDER BY awarddate"); while($row=mysql_fetch_assoc($res)){ $type=$row['awardtype']; $awarduser=$row['awarduser']; $awarduser2 = $_GET['user']; echo show_league_image($type) } ?> This just won't work, however when I remove the WHERE, it will? Link to comment https://forums.phpfreaks.com/topic/165735-solved-calling-nothing/ Share on other sites More sharing options...
onthespot Posted July 12, 2009 Author Share Posted July 12, 2009 anyone? Link to comment https://forums.phpfreaks.com/topic/165735-solved-calling-nothing/#findComment-874274 Share on other sites More sharing options...
Prismatic Posted July 12, 2009 Share Posted July 12, 2009 Can anyone understand this problem? I am calling from a table in my database which works fine when I don't include a WHERE. However when I do, i get nothing back. The php: <?php function show_league_image($type) { $images = array ( 'league1' => 'first.jpg', 'league2' => 'second.jpg', 'league3' => 'third.jpg' ); if(array_key_exists($type, $images)) return '<img src="images/awards/'.$images[$type].'" width="16" height="36" />'; return false; } $res=mysql_query("SELECT * FROM ".TBL_AWARDS." WHERE awarduser = '$awarduser2' ORDER BY awarddate"); while($row=mysql_fetch_assoc($res)){ $type=$row['awardtype']; $awarduser=$row['awarduser']; $awarduser2 = $_GET['user']; echo show_league_image($type) } ?> This just won't work, however when I remove the WHERE, it will? You specify $awarduser2 AFTER the query, so $awarduser2 is always blank in the query. $awarduser2 = mysql_real_escape_string($_GET['user']); $res=mysql_query("SELECT * FROM ".TBL_AWARDS." WHERE awarduser = '$awarduser2' ORDER BY awarddate"); And remove $awarduser2 = $_GET['user']; from your while loop. Edit - Also, don't bump your thread after only 20 minutes. Your thread will be gotten to eventually. Link to comment https://forums.phpfreaks.com/topic/165735-solved-calling-nothing/#findComment-874277 Share on other sites More sharing options...
onthespot Posted July 12, 2009 Author Share Posted July 12, 2009 thanks a lot, that worked, lesson learnt, cheers Link to comment https://forums.phpfreaks.com/topic/165735-solved-calling-nothing/#findComment-874280 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.