代碼如下: if (!$con) {die('Could not connect: ' . mysql_error());} else{ echo "nice"."
";} mysql_select_db("test", $con); echo"get the databse"."
"; $result =mysql_query("select * from hat_province");echo"get the table"."
"; while($row = mysql_fetch_array($result)) { echo $row['id'] . " " . $row['province']; echo "
"; } 在while($row = mysql_fetch_array($result))這裡總是停住出不了結果,請問到底為什麼出不了結果
回複內容:
代碼如下: if (!$con) {die('Could not connect: ' . mysql_error());} else{ echo "nice"."
";} mysql_select_db("test", $con); echo"get the databse"."
"; $result =mysql_query("select * from hat_province");echo"get the table"."
"; while($row = mysql_fetch_array($result)) { echo $row['id'] . " " . $row['province']; echo "
"; } 在while($row = mysql_fetch_array($result))這裡總是停住出不了結果,請問到底為什麼出不了結果
確認你的資料庫連結正常後,將while迴圈放到
if($result){ while(){ }}else{ exit('have no data!');}
調試下,看為什麼停住,應該很容易調試出來問題的。
用pdo或者mysqli吧,別再用mysql_開頭的函數了