I would like why I’m unable to load a row result from mysql db
This code works and result the echo: 180(value stored in PT):
$sql = "SELECT * FROM `user` WHERE pt;";
$result = mysqli_query($conn, $sql);
if (!$result) exit("The query did not succeded");
else {
while ($row = mysqli_fetch_array($result)) {
echo $row['pt'];
}
}
this code result in nothing:
$sql = "SELECT * FROM user WHERE pt=?"; // SQL with parameters
$stmt = $conn->prepare($sql);
$stmt->bind_param("i", $pt);
$stmt->execute();
$result = $stmt->get_result(); // get the mysqli result
$usert = $result->fetch_assoc(); // fetch the data
echo $usert
testing SELECT * FROM user WHERE pt=? in phpmyadmin
1 errors were found during analysis.
Variable name was expected. (near “?” at position 38) SQL Command:
Copy DocumentationSELECT * FROM user WHERE en=? LIMIT 0.25
MySQL Messages : Documentation
#1064 – Do you have a syntax error in your SQL next to ‘? LIMIT 0.25’ on line 1
where did i go wrong and why?