Jump to content

What's wrong with my code?


ueon

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/255041-whats-wrong-with-my-code/
Share on other sites

<?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);
?>

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.