I'm running into many problems with a code I've been working on, but this one seems to come up a lot. I'm using the procedural method for coding this site, and I can't seem to find an answer to this question without the mention of OOP's, prepared statements or failed queries. The funny thing is the statement works from the website, and the string still gets added to the database so I don't think its a failed query. Can anyone help me understand what this warning statement means?
Warning: mysqli_free_result() expects parameter 1 to be mysqli_result, boolean given in .....on line (pick a number)
This is one of the codes I'm working with.
if (isset($_POST['picturesubmit']))
{
$target_path = "uploads/";
$target_path = $target_path . basename( $_FILES['profilepic']['name']);
$ext = $_FILES['profilepic']['type'];
if(($ext == "image/jpeg") || ($ext == "image/jpg") || ($ext == "image/png") || ($ext == "image/gif"))
{
$temp_file = $_FILES['profilepic']['tmp_name'];
if(move_uploaded_file($temp_file, $target_path))
{
$picture = mysqli_real_escape_string($dbc, $target_path);
$q = "UPDATE Users SET profilepic = '$picture' WHERE email = '$sessionuser' ";
$r = mysqli_query ($dbc, $q)
or trigger_error("Query: $q\n<br />MySQL Error: " . mysqli_error($dbc));
mysqli_free_result($r);
}
else
{
echo "Picture did not upload properly. please try again";
}
}
else
{
echo "Uploaded file was not an image, please try again.";
}
}