我有以下代码:
<?php
$host="database.com"; // Host name
$username="user"; // Mysql username
$password="password"; // Mysql password
$db_name="database"; // Database name
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$contact_id = mysql_real_escape_string($_GET['contact_id']);
$sql="select ( if(month(now()) < 9, year(now()) - 1, year(now())) - year(dob) - if(month(dob)<9, 0, 1) ) as ageOnLastSeptember from members_family where contact_id = '$contact_id' ";
$result=mysql_query($sql);
while($rows=mysql_fetch_array($result)){
echo $rows['ageOnLastSeptember'];
}
mysql_close();
?>
由于某种原因,它不起作用,我收到以下错误消息:
警告:mysql_fetch_array() 期望参数 1 是资源,在第 4702 行的 /record_view/index.php 中给出布尔值