警告:mysql_fetch_array() 期望参数 1 是资源,第 19 行 C:\xampp\htdocs\test\index.php 中给出的字符串
<?php
$con = mysql_connect('localhost');
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("schedule", $con);
$sql = "SELECT * FROM classes LIMIT 0,50\n";
mysql_query($sql);
IF (!$sql) {
ECHO 'broken';
};
while($row = mysql_fetch_array($sql, MYSQL_BOTH))
{
echo $row['language'] . " " . $row['level'];
echo "<br />";
}
mysql_close($con);
?>
为什么?查询在 phpmyadmin 中有效