<?php
//预编译演示
//1,创建mysqli对象
$mysqli=new mysqli("localhost","root","1234","test");
//2,创建预编译对象
$sql="insert into user1(username,password,email) value(?,?,?)";
$mysqli_stmt=$mysqli->prepare($sql);
//绑定参数
$name="xiao";
$password="23";
$email="23@qq.com";
//参数绑定
$ mysqli_stmt->bind_param("sss",$name,$password,$email);
$b=$mysqli_stmt->execute();
if(!$b){
die("操作失败");
}else{
echo "操作ok";
}
$mysqli->close();
?>
//预编译演示
//1,创建mysqli对象
$mysqli=new mysqli("localhost","root","1234","test");
//2,创建预编译对象
$sql="insert into user1(username,password,email) value(?,?,?)";
$mysqli_stmt=$mysqli->prepare($sql);
//绑定参数
$name="xiao";
$password="23";
$email="23@qq.com";
//参数绑定
$ mysqli_stmt->bind_param("sss",$name,$password,$email);
$b=$mysqli_stmt->execute();
if(!$b){
die("操作失败");
}else{
echo "操作ok";
}
$mysqli->close();
?>