如图我想输出ID号码最小的记录 的‘name’值,也就是 12....
Parse error: syntax error, unexpected T_WHILE in index.php on line 49
第1个回答 2015-06-17
<?php
$conn = mysql_connect(SAE_MYSQL_HOST_M.':'.SAE_MYSQL_PORT,SAE_MYSQL_USER,SAE_MYSQL_PASS);
$sql = "iot";
mysql_select_db($sql,$conn);
$sql2 = "SELECT * FROM `iot` ORDER BY `id` ASC LIMIT 0,1";
// echo $sql;
$query = mysql_query($sql2, $conn);
$row = mysql_fetch_array($query, MYSQL_ASSOC);
echo $row['name'];
?>追问
$conn = mysql_connect(SAE_MYSQL_HOST_M.':'.SAE_MYSQL_PORT,SAE_MYSQL_USER,SAE_MYSQL_PASS);
$sql = "iot";
mysql_select_db($sql,$conn);
$sql2 = "SELECT * FROM `iot` ORDER BY `id` ASC LIMIT 0,1";
// echo $sql;
$query = mysql_query($sql2, $conn);
$row = mysql_fetch_array($query, MYSQL_ASSOC);
echo $row['name'];
?>追问
你好 现在变成了。。。。
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in index.php on line 8
第八行是$row = mysql_fetch_array($query, MYSQL_ASSOC);
这个提示是$query没有返回资源句柄(就是没有搜索到值,返回false了)造成的。
本回答被网友采纳