可能重复:
显示来自 MYSQL 的数据;SQL语句错误
我有下面的代码显示来自 MYSQL 数据库的数据(目前正在调查 sql 注入问题)当没有找到结果时我需要插入一条错误消息......不知道在哪里定位它!我已经尝试过代码 if( mysql_num_rows($result) == 0) { echo "No row found!" 但是继续出现语法错误,有人知道代码中的正确位置吗?
--
require 'defaults.php';
require 'database.php';
/* get properties from database */
$property = $_GET['bedrooms'] ;
$sleeps_min = $_GET['sleeps_min'] ;
$availability = $_GET['availability'] ;
$query = "SELECT * FROM `properties` WHERE bedrooms = '{$bedrooms}' AND sleeps_min = '{$sleeps_min}' AND availability = '{$availability}'";
$row=mysql_query($query);
$result = do_query("SELECT * FROM `properties` WHERE bedrooms = '{$bedrooms}' sleeps_min = '{$sleeps_min}' AND availability = '{$availability}'", $db_connection);
while ($row = mysql_fetch_assoc($result))
{
$r[] = $row;
}
?>