Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MYSQL_RESULT problem

Status
Not open for further replies.

UnclearHorizon

Programmer
Oct 23, 2001
8
US
this code right here is giving me trouble, it always ends up saying 'User not found!' which should only be said if the user doesnt exist in my database, but he does...
the variables are:
id: auto_incremented value assigned to users
login: login name of user
status: if they are logged in or not

i have a WORKING script that is nearly the same that searches by id and echos login/status if($login)... maybe because ID is an integer? or because it is indexed?

if this post is confusing, just tell me and ill try to repost it better



$query = "select id, status from account where login=$login";

$result = @MYSQL_QUERY($query);

$id = @MYSQL_RESULT($result,0,"id");
$status = @MYSQL_RESULT($result,0,"status");

echo "ID:";

if($id)
{
echo $id;
}
else
{
echo"User Not Found!";
}

echo &quot;<br>&quot;;
echo &quot;USER:&quot;;
echo $login;

if($id)
{
echo &quot;<br>STATUS:&quot;;
echo $status;
}
 
ok i made an account with login = '1' and it works, so i guess i have to use an integer. is there anyway around this?
 
nevermind, i figured it out...
this:
$query = &quot;select id, status from account where login=$login&quot;;
needs to be this:
$query = &quot;select id, status from account where login=\&quot;$login\&quot;&quot;;
the differnece:\&quot;$login\&quot; instead of just $login...the &quot;s saved the day! thnx
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top