任何人都可以在我的PHP代码中发现任何错误吗?
<?php
$keyword=$_GET['keyboards'];
$sql = "SELECT *FROM MyGuests WHERE lastname LIKE '$keyword'";
$result=mysqli_query($conn,$sql);
$sss=mysqli_num_rows($result);
if($sss)
{
while($row=mysqli_fetch_object($result)){
**echo "id: " . $row['lastname']. "<br>";**
}
}
?>
问题在这里:
echo "id: " . $row['lastname']. "<br>";
答案 0 :(得分:-1)
尝试
while ($row =$result->fetch_object()) {
echo $reg->lastname;
}
或
while ($row =$result->fetch_object()) {
echo $reg['lastname'];
}