ueon Posted January 15, 2012 Share Posted January 15, 2012 SELECT a.*, b.* FROM friendlist a INNER JOIN attend b ON (a.friendemail=b.email) WHERE a.email='$email' GROUP BY b.eventid ORDER BY count(*) DESC LIMIT 5 This query returns the right results in PHPmyadmin, but when it's executed in a php file through the chrome or firefox, it doesn't display anything. As in the entire webpage won't show up. In chrome, it says server error any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/255041-whats-wrong-with-my-code/ Share on other sites More sharing options...
AyKay47 Posted January 15, 2012 Share Posted January 15, 2012 this has nothing to do with the query, the error lies somewhere else in your code. Quote Link to comment https://forums.phpfreaks.com/topic/255041-whats-wrong-with-my-code/#findComment-1307744 Share on other sites More sharing options...
ueon Posted January 15, 2012 Author Share Posted January 15, 2012 <?php $events = mysql_query("SELECT a.*, b.* FROM friendlist a INNER JOIN attend b ON (a.friendemail=b.email) WHERE a.email='$email' GROUP BY b.eventid ORDER BY count(*) DESC LIMIT 5"); ?> this is all i have in the page Quote Link to comment https://forums.phpfreaks.com/topic/255041-whats-wrong-with-my-code/#findComment-1307745 Share on other sites More sharing options...
AyKay47 Posted January 15, 2012 Share Posted January 15, 2012 where is your link establishment using mysql_connect? Quote Link to comment https://forums.phpfreaks.com/topic/255041-whats-wrong-with-my-code/#findComment-1307747 Share on other sites More sharing options...
ueon Posted January 15, 2012 Author Share Posted January 15, 2012 <?php include "base.php"; $events = mysql_query("SELECT a.*, b.* FROM friendlist a INNER JOIN attend b ON (a.friendemail=b.email) WHERE a.email='$email' GROUP BY b.eventid ORDER BY count(*) DESC LIMIT 5"); ?> it still doesn't work :s it's giving me a 500 error Quote Link to comment https://forums.phpfreaks.com/topic/255041-whats-wrong-with-my-code/#findComment-1307752 Share on other sites More sharing options...
AyKay47 Posted January 15, 2012 Share Posted January 15, 2012 what is the contents of base.php? Quote Link to comment https://forums.phpfreaks.com/topic/255041-whats-wrong-with-my-code/#findComment-1307758 Share on other sites More sharing options...
jonsjava Posted January 15, 2012 Share Posted January 15, 2012 <?php include "base.php"; $events = mysql_query("SELECT a.*, b.* FROM friendlist a INNER JOIN attend b ON (a.friendemail=b.email) WHERE a.email='$email' GROUP BY b.eventid ORDER BY count(*) DESC LIMIT 5"); ?> You aren't executing the code. Nowhere do you actually call $events, which would then have PHP execute the query that resides in the variable. Also, you do nothing with the data it may return. Try this: <?php include "base.php"; $sql = "SELECT a.*, b.* FROM friendlist a INNER JOIN attend b ON (a.friendemail=b.email) WHERE a.email='$email' GROUP BY b.eventid ORDER BY count(*) DESC LIMIT 5;"; $res = mysql_query($sql) or die("Error!<br />".mysql_error()); while ($row = mysql_fetch_assoc($res)){ $out[] = $row; } var_dump($out); ?> Quote Link to comment https://forums.phpfreaks.com/topic/255041-whats-wrong-with-my-code/#findComment-1307778 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.