在第二台机器上运行PHP查询问题

时间:2014-03-11 17:11:58

标签: php sql mysqli

当我在machine a上使用mysqli运行以下代码时,执行查询和查看数据没有问题。但是在machine b上,我收到以下错误:

  

警告:mysqli_stmt :: bind_param():无效的对象或资源mysqli_stmt

我不确定为什么会这样。这个错误是否发生在其他任何人的机器上?

<?php 
$dbHost = "localhost";
$dbUser = 'ben2';
$dbPass = 'ben';
$dbname = 'test';

$mysqli = new mysqli($dbHost, $dbUser, $dbPass, $dbname);
 if ($mysqli->connect_error) {
    die('Connect Error (' . $mysqli->connect_errno . ') '
        . $mysqli->connect_error);
}

$firstname = "David";
$lastname = "Peterson";

$stmt = $mysqli->stmt_init();
$stmt->prepare("INSERT INTO test (fn, ln) VALUES (?, ?)");
$stmt->bind_param("ss", $firstname, $lastname);
$stmt->execute();   
?>

0 个答案:

没有答案