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
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`=name@blah.edu

 

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` = "name@blah.edu"

 

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.