PHP语句的问题. (mysqli) [英] php statement question. (mysqli)

查看:52
本文介绍了PHP语句的问题. (mysqli)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

$db = new mysqli('localhost','root','nere','deneme');

if ($db->error)
exit();

$stmt = $db->prepare("INSERT INTO deneme VALUES (?,?,?)");

$stmt->bind_param('ssi',$adi,$soyadi,$no);

$adi='recep';
$soyadi='saban';
$no=5;

$stmt->execute();

我出错了.

Fatal error: Call to a member function bind_param() on a non-object in C:\wamp\www\rock\index.php on line 10

我做错了什么?

推荐答案

应该类似于以下内容.另外,在将值传递给bind_param()

it should be something like below. Also you should assign the values to the variables before passing it to bind_param()

if ($db->error)
exit();

if ($stmt = $db->prepare("INSERT INTO deneme VALUES (?,?,?)")) {
$adi='recep';
$soyadi='saban';
$no=5;

$stmt->bind_param('ssi',$adi,$soyadi,$no);


$stmt->execute();
}

告诉您应该在数据库中填充哪些列也是一个好主意:

It's also a good idea to tell which columns should be populated in your database:

INSERT INTO deneme (column1, column2, column3) VALUES (?,?,?)

这篇关于PHP语句的问题. (mysqli)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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