Results 1 to 6 of 6

Thread: Return of the db errors...

  1. #1

    Thread Starter
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Thumbs down Return of the db errors...

    I'm trying to create a simple login. Here's my PHP code for verifying if the username and password are correct.

    PHP Code:
    <?
    $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?

  2. #2
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    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.

  3. #3

    Thread Starter
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    NYYAAAAAAAAAAAAAAAAARRRRGGGGGGGHHHHHHHHH

  4. #4
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    what was that for?????


  5. #5

    Thread Starter
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Frustration over a silly error.

    Thanks, problem solved.

  6. #6
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    hehe ok

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width