PDA

Click to See Complete Forum and Search --> : Return of the db errors...


mendhak
Jun 25th, 2003, 12:00 AM
I'm trying to create a simple login. Here's my PHP code for verifying if the username and password are correct.


<?
$username = $_POST['username'];
$password = $_POST['password'];

$dbh=mysql_connect("localhost","root","");
mysql_select_db("mendhak");

$LOGINQUERY = "SELECT * FROM members WHERE username = '$username' AND pasword = '$password'";

$result = mysql_result($loginquery);
mysql_close();
echo $username;
echo $password;
$ifexists = mysql_numrows($result);
echo $ifexists;
?>


In the database, I have a user existing, mendhak and password mendhak. This is the error message I get:


Warning: Wrong parameter count for mysql_result() in C:\web\login.php on line 10

mendhakmendhak <-- these are the echo commands up there in the code

Warning: mysql_numrows(): supplied argument is not a valid MySQL reslut resource in C:\web\login.php on line 14



I can't see why it shouldn't be working. I'm using a simple SELECT statement on the members table. By the way, the members table has three fields: username, password and email.

What am I doing wrong?

phpman
Jun 25th, 2003, 11:34 AM
mysql_result needs 2 parameters. and it will only return 1 result, not all 3. fix this and I bet the rest go away.

mysql_result ( resource result, int row )

to get all the results you need mysql_fetch_array(), not mysql_result()

oh and

$LOGINQUERY

$loginquery

those are very different variables.

mendhak
Jun 25th, 2003, 05:03 PM
NYYAAAAAAAAAAAAAAAAARRRRGGGGGGGHHHHHHHHH :mad:

phpman
Jun 25th, 2003, 09:06 PM
what was that for?????

:confused:

mendhak
Jun 26th, 2003, 02:13 AM
Frustration over a silly error.

Thanks, problem solved.

phpman
Jun 26th, 2003, 08:24 AM
hehe ok :)