Page 1 of 1

[SOLVED] Simple membership script errors

Posted: Thu Jul 15, 2004 5:52 pm
by Tsuki
I've been working on a simple membership script for my site, but I keep having 2 errors in the login script. I've looked over the trouble spots 5 million times, it seems, but I can't pin point the problem. Can anyone help me?

Here's the code:

Code: Select all

<?php
// Match Row in Database 
$qChk = "select name from membership where name=='$name' and password=='$password' and (status=='Y' || status=='A' || status=='O' || status=='R') "; 
$rsChk = mysql_query($qChk); 
?>
$rowCount = mysql_num_rows($rsChk) or die(mysql_error()); // how many rows returned from our query

And the Errors:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\Program Files\Apache Group\Apache2\htdocs\chibi\Membership\login.php on line 28
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 '=='Cookie_Monster' and password=='xxxx' and (status=='Y' || s
I got most the scrpit from a toutorial, but I added the multiple status checks, and I honestly wasn't sure if that would work, but that doesn't seem to be the problem.

Posted: Thu Jul 15, 2004 5:54 pm
by feyd
= not ==

Posted: Thu Jul 15, 2004 6:01 pm
by Joe
$qChk = "SELECT name FROM membership WHERE name='$name' AND password='$password' AND status='Y' OR status='A' OR status='O' OR status='R' ";

Posted: Thu Jul 15, 2004 11:59 pm
by Tsuki
OK, thanks that worked great! I just have one small problem left. When I try to log in w/ a name that is status O it works fine, but when I try to login w/ a name that is status Y it says the name/password combo does not match or I haven't been activated yet. Any ideas?

EDIT: Oh, I found the problem. I just had to put the status variables back in the parenthese. :D Thanks so much!

Posted: Fri Jul 16, 2004 12:03 am
by feyd

Code: Select all

$qChk = "SELECT name FROM membership WHERE name='$name' AND password='$password' AND (status='Y' OR status='A' OR status='O' OR status='R') ";

Posted: Fri Jul 16, 2004 12:04 am
by Tsuki
Oh, heh. I just found that out. Thanks a bunch!