Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    I Keep getting a error in this Warning: mysql_fetch_array(): supplied argument is not

    Hello everyone,

    I keep getting this fool less error.
    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /usr/home/yvtproc/public_html/Authentication/checkuser.php on line 18.

    Code:
    <?php
    if (isset($_SERVER["PHP_AUTH_USER"])) {
      $user = $_SERVER["PHP_AUTH_USER"];
      $pass = $_SERVER["PHP_AUTH_PW"];
    } elseif (isset($_SERVER["HTTP_AUTHORIZATION"])) {
      if (substr($_SERVER["HTTP_AUTHORIZATION"], 0, 5) == "Basic") {
        $userpass = split(":" ,
          base64_decode(substr($_SERVER["HTTP_AUTHORIZATION"], 6)));
           $user = $userpass[0];
           $pass = $userpass[1];
         }
       }
    
    $auth = false;
    $pwdb = mysql_connect("localhost", "mysql_user", "mysql_password");
    mysql_select_db("auth", $pwdb);
    $rows = mysql_query("SELECT user, pass FROM users", $pwdb); 
    while ($row = mysql_fetch_array($result)) {
    
    if ($user == $row["user"] && crypt($pass, "pw") == $row["pass"]) {
        $auth = true;
        break;
              }
           }
              
    if (!$auth) {
      
      }
    ?>
    I been over and over on this script. what it suppose to be doing is checking the username and password that i added with another script. Could anyone help me out on this subject?

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,852
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Change
    Code:
    $rows = mysql_query("SELECT user, pass FROM users", $pwdb);
    to
    Code:
    $rows = mysql_query("SELECT user, pass FROM users", $pwdb) or die(mysql_error());
    and check gain.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    also replace mysql_fetch_array with mysql_fetch_assoc if you use a hash array or use a second argument to force a hash assoc.

    best regards


  •  

    Posting Permissions

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