我是php新手,下面是我做的。输出为012345,表示$result= $pre->get_result();
有问题。
P.S。我试图在$pre->bind_param('i',$id);
使用int而不是String,但它具有相同的输出。
<?php
require 'Connections/pplcon.php';
header("Content-Type:text/html; charset=utf-8");
mysqli_set_charset( $conn, 'utf8');
?>
<?php
/* activate reporting */
$driver = new mysqli_driver();
$driver->report_mode = MYSQLI_REPORT_ALL;
$id="1";
//Created a template
echo 0;
$sql = "SELECT * FROM Coupon WHERE ActivityID = ?";
//Create a prepared statement
echo 1;
if($pre = $conn->prepare($sql)) {
echo 2;
$pre->bind_param('s',$id);
echo 3;
echo 4;
$pre->execute();
echo 5;
$result= $pre->get_result();
echo 6;
if ($result->num_rows > 0) {
while ($row = mysqli_fetch_assoc($result)) {
echo $row['ActivityID'] . "<br>";
}
}
}
else {
echo 0;
}
?>