我試圖從一個mysql數據庫中獲取數據,並將登錄信息保存在另一個文件中。用戶名正從我的形式發送到與代碼的網頁,我得到一個PHP解析數據庫搜索結果返回錯誤
Parse error: syntax error, unexpected '[', expecting ',' or ';' in C:\xampp\htdocs\waladmin\ipfinder.php on line 31.
我不明白爲什麼它說,雖然,一切都看起來不錯。
這裏是我的PHP:
<?php
testinclude('db_login.php');
$con = mysql_connect($db_host,$db_username,$db_password);
//$con = mysql_connect('10.241.10.40','waladmin','waladmin');
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$db_select=mysql_select_db($db_database);
if(!db_select)
{
die("Could not select the database. <br />".mysql_error());
}
$select = ' Select ';
$column = ' IP_Address,Workstation,Username ';
$from = ' FROM ';
$tables = ' admintable ';
$where = ' where Username = " & ControlChars.Quote & Username & Username & ControlChars.Quote & "ORDER BY admintable.Time_Stamp DESC';
$query = $select.$column.$from.$tables.$where;
$result = mysql_query($query);
if(!result)
{
die("Could not query the database: <br />".mysql_error());
}
while($result_row = mysql_fetch_row(($result))){
echo 'Username: ' . result_row[2] . ' <br /> ';
echo 'Workstation: ' . result_row[2] . ' <br /> ';
echo 'IP Address: ' . result_row[1] . ' <br /> ';
}
echo $con;
mysql_close($con)
echo $con;
?>
[參考 - 這個錯誤在PHP中意味着什麼?](http://stackoverflow.com/q/12769982/367456) – hakre