[SOLVED] Simple membership script errors

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Tsuki
Forum Newbie
Posts: 3
Joined: Thu Jul 15, 2004 5:52 pm
Location: A world based on 1s and 0s
Contact:

[SOLVED] Simple membership script errors

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

= not ==
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

Post 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' ";
Tsuki
Forum Newbie
Posts: 3
Joined: Thu Jul 15, 2004 5:52 pm
Location: A world based on 1s and 0s
Contact:

Post 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!
Last edited by Tsuki on Fri Jul 16, 2004 12:04 am, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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') ";
Tsuki
Forum Newbie
Posts: 3
Joined: Thu Jul 15, 2004 5:52 pm
Location: A world based on 1s and 0s
Contact:

Post by Tsuki »

Oh, heh. I just found that out. Thanks a bunch!
Post Reply