<?php
define('DB_NAME', 'salesinformation');
define('DB_USER', 'root');
define('DB_PASSWORD', '');
define('DB_HOST', 'localhost');
$link = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link) {
die('Cannot connect: ' . mysqli_error());
}
$db_selected = mysqli_select_db(DB_NAME, $link);
if(!$db_selected){
die('Cannot use ' . DB_NAME . ': ' . mysqli_error());
}
<!-- THIS IS LINE 20 BELOW -->
$result = ($link, "SELECT `description`,`price`,`date`,`shape` FROM `sales` WHERE 1");
echo "<table border='1'>
<tr>
<th>description</th>
<th>price</th>
<th>date</th>
<th>shape</th>
</tr>";
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['description'] . "</td>";
echo "<td>" . $row['price'] . "</td>";
echo "</tr>";
}
echo "</table>";
if (!mysqli_query($result)){
die('Error: ' . mysqli_error());
}
mysql_close();
?>
解析错误:语法错误,意外','在第20行的C:\ xampp \ htdocs \ recieve.php
数据库工作,我可以向它发送数据。现在,当我尝试用上面的PHP代码读取它时,我得到了一个我不明白的错误。语法有什么问题?
答案 0 :(得分:4)
您没有在该行上调用任何方法。
$result = ($link, "SELECT...");
需要改为:
$result = mysqli_query($link, "SELECT...");