我在我的SQL语法中遇到了问题,我希望它作为字符串返回或至少显示语法的结果。无法转换为字符串
我的代码是:
<?php
$host='localhost';
$user='root';
$password='';
$db='employee101';
$PLATE_NUM = 'ABC123';
$sql = "select * from employee_data where PLATE_NUM like '$PLATE_NUM';";
$con = mysqli_connect($host,$user,$password,$db);
$result = mysqli_query($con, $sql);
$response = array();
$myText = (string)$result;
$row = mysql_fetch_array($result);
echo $result->fetch_object()->memTotal;
mysqli_close($con);
?>
是我得到的错误:
Catchable fatal error: Object of class mysqli_result could not be converted to string in C:\wamp64\www\666.php on line 17
为什么你把它铸造成字符串! 更改这两行: '$ myText = $ result; $ row = mysqli_fetch_array($ result);' – Mohammad
什么是字符串铸造? – rtfm