0
我有一個PHP代碼,將使用數據庫中選擇MySQL中的最後一排,但這個錯誤出來:選擇在數據庫中最後一行不工作使用PHP
syntax error, unexpected '$result' (T_VARIABLE)
我的PHP代碼:
$con = mysqli_connect("localhost","root","","productno") or die("Error " . mysqli_error($con));
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con, "SELECT Alibaba FROM records ORDER BY Date DESC LIMIT 1");
if (mysqli_num_rows($result) > 0)
{
$s_Alibaba = mysqli_fetch_row($result);
$sql_Alibaba = $s_Alibaba[0]; //Compare with the last record
}
echo $sql_Alibaba;
任何想法如何解決它?謝謝
哪'$ result'是它在說什麼?你的代碼中有三個'$ results'。 – Albzi 2014-11-21 09:09:59
$ result = mysqli_query($ con,「SELECT Alibaba FROM records ORDER BY Date DESC LIMIT 1」); //應該是這個 – Cael 2014-11-21 09:11:55
如果你迴應mysqli-error會輸出什麼內容?在查詢之後'echo mysqli_error($ con)'? – Giwwel 2014-11-21 09:13:10