我使用一个ins函数插入数据库中,并为mysqli创建了一个对象.mysqli对象显示了未定义变量的错误,而我的代码是
<?php
include "config.php";
global $mysqli;
$mysqli = &new mysqli($host, $db_user, $db_pass, $db);
function ins($name)
{
$stmt=$mysqli->prepare("insert into table demo values(?)");
$stmt->bind_param("s",$name);
$stmt->execute();
$stmt->close();
}
ins("krishna");
?>
这里服务器名,用户名密码和数据库名存储在config.php中