<?php
 header("Content-type:text/html;charset=utf-8");    //设置编码
 $servername = "localhost";
 $username = "root";
 $dbname = "test";
 // 创建连接
 $conn = mysqli_connect($servername, $username,'', $dbname);
 // 检测连接
 if (mysqli_connect_errno($conn)) {
 
     die("连接失败: " .  mysqli_connect_error());
 
 } else {
     $sql = "INSERT INTO MyGuests VALUES(?, ?, ?)";
     // 为 mysqli_stmt_prepare() 初始化 statement 对象
     $stmt = mysqli_stmt_init($conn); 
     //预处理语句 
     if (mysqli_stmt_prepare($stmt,$sql)) {
         // 绑定参数
         mysqli_stmt_bind_param($stmt, 'sss', $firstname, $lastname, $email);
         // 设置参数并执行
         $firstname = 'liu';
         $lastname = 'Doe';
         $email = '[email protected]';
         mysqli_stmt_execute($stmt);
 
         $firstname = 'zhang';
         $lastname = 'Moe';
         $email = '[email protected]';
         mysqli_stmt_execute($stmt);
 
         $firstname = 'li';
         $lastname = 'Dooley';
         $email = '[email protected]';
         mysqli_stmt_execute($stmt);
     }
 }
 ?>
$stmt  不知道为什么是null