[thelist] PHP/MySQL help required

Dave Stevens stem at stemofficial.co.uk
Sat Feb 2 19:57:00 CST 2002


actually sat down to do some of my ALevel Computing project tonight, ended
up getting driven crazy by this little bit:

basically, I want the script to compare $password (a variable taken from a
text box on a form) with "password" (a row in my customers table) and if
they are the same, put out the relevant code as stated. However, all I get
is:

Warning: Supplied argument is not a valid MySQL result resource in
/home/sites/site108/web/mrw/customers/login.php on line 18

here is the main part of the code:

$sql = "SELECT * FROM customers WHERE username=$username";

        $result = mysql_query($sql);

        $myrow = mysql_fetch_array($result);

 if ($password == $myrow["password"]) {
          $currentuser = $username;
          printf("Welcome back, %s. You can now order from our <a
href=\"../catalogue.php\">catalogue</a>.", $currentuser);

          } else {
          echo "incorrect password.";
          }

disclaimer: I am very new to PHP and MySQL, and as such this code will no
doubt make some people here cringe...sorry!
many thanks in advance for any help!
dave stevens




More information about the thelist mailing list