Forum Moderators: coopster
$result = mysql_query ("SELECT password FROM users WHERE username=$username",$link);
$row = mysql_fetch_array($result);
if ($_POST['password'] == $row['password']){
$loggedin = 1;
}
The error I'm getting says "Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource". I'm probably just making a simple mistake but I can't find it.
Thanks in advance.
One way to troubleshoot problems like this is to create your query statement as a separate variable and exit [php.net] your code. This will halt all processing and output the $sql variable to your browser so you can see where the statement isn't looking right. I noticed you are not enclosing your password string in quotation marks. MySQL specifies that string and date values are specified as quoted strings.:
$sql= "SELECT password FROM users WHERE username='$username'";
//exit($sql); // uncomment this line to preview your statement.
$result = mysql_query ($sql,$link);