This is the error i am getting
I am using the example from php.net, i am unsure as to why the application is crashing?Code:Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\Student Planner\account.php on line 40
Thats the code I am usingPHP Code:if($_POST['email']==""||$_POST['password']=="")
{
$berror=1;
$message.="<p>Please complete all fields</p>";
}
else
{
$sql="SELECT * FROM student_users WHERE id = '" . $_SESSION['userid'] . "' LIMIT 1";
$result = mysql_query($sql);
if (!$result)
{
$berror=1;
$message.="<p>Could not successfully run query ($sql) from DB: " . mysql_error() . "</p>";
}
else
{
if(mysql_num_rows($result)==0)
{
$berror=1;
$message.="<p>No rows found, nothing to print so am exiting</p>";
}
else
{
while ($row = mysql_fetch_assoc($result)) // THIS IS LINE 40
{
if($row['password']==md5($_POST['password']))
{
$sql="UPDATE student_users Set email = '" . $_POST['email'] . "' WHERE id = '" . $_SESSION['userid'] . "'";
$result = mysql_query($sql);
if (!$result)
{
$berror=1;
$message.="<p>Could not successfully run query ($sql) from DB: " . mysql_error() . "</p>";
}
}
else
{
$berror=1;
$message.="<p>Incorrect password</p>";
}
}
}
}
}


Reply With Quote