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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Returning a 0 or 1 from a query

Status
Not open for further replies.

newphpbie

Programmer
Joined
Oct 17, 2003
Messages
110
Location
GB
Hi all,

I am trying to return a value of either 1 or 0 depending on if the record exsists or not.

The user will type in a password.. $pass

I want to check for a record of this password in a db...
Code:
$query="SELECT userID FROM users WHERE userPass="'.$pass.'"  ";

I need the code to return a value of 0 if the record doesn't exsist, or a 1 if it does....or something similar to that.

Can anyone help please...
 
Code:
$query="SELECT userID FROM users WHERE userPass="'.$pass.'"  ";
$rs=mysql_query($query,$conn);
$aantal=mysql_num_rows($rs);

if ($aantal==1) {succeeded} else {wrong}

 
Worked around it, but I'll give what you say a try.

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top