Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/269.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 致命错误:对非对象调用成员函数bind_param()_Php_Mysql_Database_Mysqli - Fatal编程技术网

Php 致命错误:对非对象调用成员函数bind_param()

Php 致命错误:对非对象调用成员函数bind_param(),php,mysql,database,mysqli,Php,Mysql,Database,Mysqli,我这里有3个表格:用户、发布项目和照片上传。在我实现照片上传之前,一切都正常 我说了一个错误 $stmt = $db->prepare("SELECT post_id,content,date,category_id,lp_title,lp_image,lp_canonicalUrl,lp_url,lp_desc,lp_iframe,lp_iframe_id,img_src FROM post_items INNER JOIN user ON post_items.user_id

我这里有3个表格:用户、发布项目和照片上传。在我实现照片上传之前,一切都正常

我说了一个错误

$stmt = $db->prepare("SELECT post_id,content,date,category_id,lp_title,lp_image,lp_canonicalUrl,lp_url,lp_desc,lp_iframe,lp_iframe_id,img_src
    FROM post_items INNER JOIN user ON post_items.user_id = user.user_id INNER JOIN photo_upload ON post_items.post_id = photo_upload.post_id
     WHERE post_items.user_id = ? AND post_items.post_id = photo_upload.post_id order by post_items.post_id desc LIMIT ?,?");


$stmt->bind_param('iii', $userid, $itemStart, $itemEnd);
文件中提到它返回:

mysqli_prepare()返回语句对象,如果发生错误,则返回FALSE

请尝试以下操作:

Fatal error: Call to a member function bind_param() on a non-object in

您是否尝试过转储$stmt变量<代码>变量转储($stmt)(在调用bind_param之前执行此操作。是的,它表示false。但我无法找出我的sqlLIMIT中的wat错误?,?似乎是错误的。您没有给prepare方法它需要在请求中放置的参数。@Loïc我的限制在此之前起作用。可能是第二个不支持限制的地方?我希望加入post_items&photo_upload?h2ooooo方法很好,它将向您显示mysql错误消息。致命错误:调用未定义的方法mysqli::errorInfo()@user3346088抱歉-以为您使用了PDO。我已更新了我的答案:)我使用$db->error abd received字段列表中的“post_id”列是ambiguous@user3346088这是因为您要加入的多个表有一个
post\u id
列。您应该使用
AS
命名它们,并通过
pu.post\u id
photo\u upload.post\u id
引用它们。
$stmt = $db->prepare("SELECT post_id,content,date,category_id,lp_title,lp_image,lp_canonicalUrl,lp_url,lp_desc,lp_iframe,lp_iframe_id,img_src
    FROM post_items INNER JOIN user ON post_items.user_id = user.user_id INNER JOIN photo_upload ON post_items.post_id = photo_upload.post_id
     WHERE post_items.user_id = ? AND post_items.post_id = photo_upload.post_id order by post_items.post_id desc LIMIT ?,?");

if ($stmt !== false) {
    $stmt->bind_param('iii', $userid, $itemStart, $itemEnd);
} else {
    print_r( $db->error );
}