$req_user = trim($_GET['user']);
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$get_data = "SELECT * FROM `users` WHERE uname = '$req_user'";
$result = mysql_query($get_data) OR die(mysql_error());
$rows = mysql_fetch_assoc($result);
$email = $rows['email'];
$gravatar = md5(strtolower(trim("$email")));
$user_likes = mysql_query("SELECT COUNT(*) FROM likes WHERE username = '$email'");
I'm trying to count all of the rows in the database likes
with the email of the current user in their username
field.
(It's a loop to get info from links like userinfo.php?user=xxx
.)
When I echo $user_likes
there is no output.
What is wrong with the code?
http://www.tutorialspoint.com/mysql/mysql-count-function.htm