我遇到了一些我一直在研究的代码问题,但是这个代码似乎出现了很多。我正在使用程序方法对此站点进行编码,如果没有提及OOP,准备好的语句或失败的查询,我似乎无法找到这个问题的答案。有趣的是该声明在网站上起作用,字符串仍然被添加到数据库中,因此我认为它不是一个失败的查询。任何人都可以帮我理解这个警告声明的含义吗?
警告:mysqli_free_result()期望参数1为mysqli_result,在线上给出布尔值(选择一个数字)
这是我正在使用的代码之一。
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.";
}
}
答案 0 :(得分:1)
mysqli_free_result
mysqi_query
参考文档: - http://php.net/manual/en/mysqli.query.php
失败时返回FALSE。对于成功的SELECT,SHOW,DESCRIBE或EXPLAIN查询,mysqli_query()将返回一个MySQLi_Result对象。对于其他成功的查询,mysqli_query()将返回TRUE。