Jump to content

Query was empty?!?


vajona

Recommended Posts

I'm not sure what i have done wrong here...

all it says is "Query was empty"

 

<?php
SESSION_START();

?>

//some html

<?php

if($_SESSION['email']){

$mysql = "SELECT id,firstname FROM users WHERE 'id'='".$_SESSION['email']."'";
$res = mysql_query($sql) or die(mysql_error());

if(mysql_num_rows($res) == 0){
	session_destroy();
	echo"Please <a href=\"/index.html\">Login</a> or <a href=\"/register.php\">Join Us.</a>";
}else{
	$row = mysql_fetch_assoc($res);
	echo "welcome back, <a href=\"./index.php?act=profile&id=".$row['id']."\">".$row['firstname']."</a>\n";

}
}else {
echo"Please <a href=\"/index.html\">Login</a> or <a href=\"/register.php\">Join Us.</a>";

}
?>

Link to comment
https://forums.phpfreaks.com/topic/219349-query-was-empty/
Share on other sites

update:

 

i changed my script to

 

$mysql = "SELECT * FROM users WHERE `email`=".$_SESSION['email']."";

 

and when i echo it out i get

 

SELECT * FROM users WHERE `id`[email protected]

 

when i go to PHPMYADMIN and run it as a query i get

 

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@blah.edu LIMIT 0, 30' at line 1

 

however; if i simply put " " around the email in the query window

 

SELECT * FROM users WHERE `email` = "[email protected]"

 

gives me the correct value which is greater than 0

 

so my question now is how do i get it to look like that when i echo it out. i really hope that makes sense

 

also i would like to thank you for helping. i know it's like pulling teeth. i am trying my hardest to learn everything i can about how to script.

Link to comment
https://forums.phpfreaks.com/topic/219349-query-was-empty/#findComment-1137583
Share on other sites

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.