我在我的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