我试图连接一系列在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上运行得很好,但这种情况仍在发生。

任何帮助表示赞赏。

  ask by user3552779 translate from so

本文未有回复,本站智能推荐:

关注微信公众号