非对象上的函数 bind_param() |PHP MySQL [英] Function bind_param() on a non-object | PHP MySQL

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

问题描述

我用准备好的语句编辑了我的代码(我以前没有使用过它们).我收到一个错误在非对象上调用成员函数 bind_param()".我用谷歌搜索了那个错误,我找到了原因 - 如果查询有语法错误,就会导致错误.我在查询中查看了最后 10 分钟,但找不到语法错误.有人可以帮助我吗?谢谢!

I edited my code with prepared statments(I didn't used them before). I get an error "Call to a member function bind_param() on a non-object". I googled that error and I found cause - error is caused if query has syntax error. I'm looking last 10 minutes in query and I can't find syntax error. Can somebody help me? Thanks!

// QUERY BEFORE
$_hsync_statment->bind_param("sisssss", $_hsync_ime, $_hsync_id, $_hsync_nista, $_hsync_nista, $_hsync_mail, $_hsync_datum, $_hsync_vrijeme);
if(!$_hsync_statment->execute()) $_hsync_reg_status = -1;

// POVEČAVA BROJ REGISTRIRANIH RAČUNA
$_hsync_statment = $_hsync_konekcija->prepare("UPDATE $_hsync_srv SET Clanova = ?");
$_hsync_statment->bind_param("i", $_hsync_id + 1); // THIS LINE
if(!$_hsync_statment->execute()) $_hsync_reg_status = -1;

我试图在每个语句执行后关闭它.那没有帮助.

I tried to close every statment after it gets executed. That doesn't help.

推荐答案

那么

$_hsync_statment->bind_param("i", $_hsync_id + 1); // THIS LINE

事实上,$_hsync_id 是一个保存 int 的变量.当你将 1 添加到 int 时.它产生一个对于 bind_param 不可接受的 int.bind_param 需要一个对象.试试这个:

The fact that $_hsync_id is a variable that holds an int. when you add 1 to int. It produces an int that's not acceptable to bind_param. bind_param expects an object. Try this:

$_hsplus = $_hsync_id + 1;
$_hsync_statment->bind_param("i", $_hsplus); // THIS LINE

那么现在为什么我在 manual 明确地说:

So now why did I get two downvotes when the manual clealy says:

注意 mysqli_stmt_bind_param() 需要传递参数参考,而

Note that mysqli_stmt_bind_param() requires parameters to be passed by reference, whereas

这篇关于非对象上的函数 bind_param() |PHP MySQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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