I am new in php, the below is what I did. The output is 012345, that means $result= $pre->get_result();
has problem.
P.S. I tried to use int instead of String here $pre->bind_param('i',$id);
, but it has the same output.
<?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;
}
?>