我尝试连接在Dreamweaver上创建的一系列五个选择菜单,以通过下面的查询生成一个结果。每次运行查询时我都会遇到错误。这是我在PHP页面上的查询:
enter code here
<?php
$connect= mysql_connect("localhost","root", "password");
// Check connection
if (!mysql_select_db('db_name', $connect)) {
echo 'Could not select database';
exit;
}
$sql = "SELECT SER_ID and ser_type FROM services
INNER JOIN service_type ST
ON s.SER_ID= st.SER_ID
inner join profile P
on st.P_ID = p.P_ID
inner join room_services rs
on rs.SER_ID = s.SER_ID
inner join room r
on r.R_ID = rs.R_ID
inner join room_sensor rse
on rse.R_ID = r.R_ID
inner join sensor sen
on sen.S_ID = rse.S_ID
inner join service_sensor ss
on ss.SER_ID = s.SER_ID
inner join services_conditions sc
on sc.SER_ID = s.SER_ID
inner join conditions c
on c.C_ID = sc.C_ID
where p.username = Adam
AND sen.sensor_type = motion detector";
$result= mysql_query($sql, $connect);
echo "<table border='1'>
<tr>
<th>ser_ID</th>
<th>service_Type</th>
</tr>";
while($row = mysql_query($result)) {
echo "<tr>";
echo "<td>" . $row['ser_ID'] . "</td>";
echo "<td>" . $row['service_Type'] . "</td>";
echo "</tr>";
}
echo "</table>";
if (!$result) {
echo "DB Error, could not query the database\n";
echo 'MySQL Error: ' . mysql_error();
exit;
}
while ($row = mysql_fetch_assoc($result)) {
echo $row['ser_ID'];
echo $row['serice_Type'];
}
mysql_free_result($result);
mysql_close($connect);
?>
enter code here
enter code here
我一直收到的错误是:
DB错误,无法查询数据库MySQL错误:查询为空
尽管查询在phpMyAdmin上运行完全正常,但仍然会发生这种情况。
任何帮助表示感谢。