mysqli_free_result 警告说明 [英] mysqli_free_result warning explaination

查看:28
本文介绍了mysqli_free_result 警告说明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在处理的代码遇到了很多问题,但这个问题似乎经常出现.我正在使用程序方法来编码这个网站,如果不提及 OOP、准备好的语句或失败的查询,我似乎无法找到这个问题的答案.有趣的是该语句在网站上有效,并且该字符串仍然被添加到数据库中,所以我认为它不是一个失败的查询.谁能帮我理解这个警告声明是什么意思?

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?

警告:mysqli_free_result() 期望参数 1 是 mysqli_result,布尔值在 .....on line 中给出(选择一个数字)

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.";
}
    }

推荐答案

mysqli_free_result 对于 write statment as mysqi_query
来说不是必需的返回布尔值 (true),
它不返回结果标识符资源,
所以你不能释放结果

mysqli_free_result is not necessary for write statment as mysqi_query
return boolean (true),
it does not return a result identifier resource,
so you can not free the result

参考文档:- http://php.net/manual/en/mysqli.query.php

失败时返回 FALSE.对于成功的 SELECT、SHOW、DESCRIBE 或 EXPLAIN 查询,mysqli_query() 将返回一个 MySQLi_Result 对象.对于其他成功的查询,mysqli_query() 将返回 TRUE.

Returns FALSE on failure. For successful SELECT, SHOW, DESCRIBE or EXPLAIN queries mysqli_query() will return a MySQLi_Result object. For other successful queries mysqli_query() will return TRUE.

这篇关于mysqli_free_result 警告说明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆