PHP致命错误:在非对象上调用成员函数bind_param() [英] PHP Fatal error: Call to a member function bind_param() on a non-object

查看:83
本文介绍了PHP致命错误:在非对象上调用成员函数bind_param()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码:

$statement = $mysqli->prepare("INSERT INTO `paypal_transactions` (`txn_id`, `payer_email`, `mc_gross`, `mc_currency`, `expires`, `userid`) VALUES (?, ?, ?, ?, " . (time() + 2678400) . ", ?)");
file_put_contents('error.txt', $mysqli->error . mysqli_error($mysqli));
$statement->bind_param('ssdsi', $txn_id, $payer_email, $payment_amount, $payment_currency, $userid);
$statement->execute();

error.txt每次都是空白,这是我在error_log文件中看到的:

error.txt is blank every single time, and this is what I see in the error_log file:

[02-Jul-2013 09:08:15 America/Denver] PHP Fatal error:  
Call to a member function bind_param() on a non-object in /home4/site/public_html/paypal.php on line 96

是指上面的代码块.

我为此付出了很多努力,我一直在试图修复它达数小时之久,但它根本无法正常工作.我的sql查询找不到任何问题,我迷失了方向,试图找出问题所在.

I am at my wits end with this, I have been trying to fix it for hours and it just won't work. I cannot find any problems with my sql query and I am losing my mind trying to figure out what's wrong.

推荐答案

似乎$statement = $mysqli->prepare(..)提供结果FALSE,所以$statement不是对象,您不能使用$statement->bind_param(..)

It seems $statement = $mysqli->prepare(..) give result FALSE so $statement is not object and you can't use $statement->bind_param(..)

$statement = $mysqli->prepare("...");

if( $statement !== FALSE ) {
    $statement->bind_param(...);
    $statement->execute();
}

PHP-MySQLi-准备

顺便说一句:您是否通过复制/粘贴直接在数据库中测试SQL查询?

BTW: Have you test your SQL query directly in database by copy/paste ?

这篇关于PHP致命错误:在非对象上调用成员函数bind_param()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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