我运行此查询
$result1 = mysql_query("SELECT * FROM 'departments'");
while($row1 = mysql_fetch_assoc($result1))
{
$depts = array("Name" => $row1['Name'], "Value" => $row1['Value'], "ID" => $row['CollegeID']);
}
使用其他三个简单查询,一个将数据加载到配置文件文本框中,另一个加载下拉列表。我的查询或我的PHP代码可能导致此错误。它只返回约51条记录。您是否认为它可能是MySQL服务器在2008 Windows Server上运行的服务器。
答案 0 :(得分:2)
也许你在departments表中有很多列。试试这个:
$result1 = mysql_query("SELECT Name, Value, CollegeID FROM 'departments'");
while($row1 = mysql_fetch_assoc($result1))
{
$depts = array("Name" => $row1['Name'], "Value" => $row1['Value'], "ID" => $row['CollegeID']);
}
答案 1 :(得分:1)
您也可以尝试使用OOP mysqli函数而不是旧的mysql版本。
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
$mysqli->query("SELECT Name, Value, CollegeID FROM departments");
答案 2 :(得分:0)
绝不使用*
$result1 = mysql_query("SELECT Name, Value, CollegeID FROM 'departments'");
while($row1 = mysql_fetch_assoc($result1))
{
$depts = array("Name" => $row1['Name'], "Value" => $row1['Value'], "ID" => $row['CollegeID']);
}
并使用LIMIT
$result1 = mysql_query("SELECT Name, Value, CollegeID FROM 'departments' LIMIT 1");
while($row1 = mysql_fetch_assoc($result1))
{
$depts = array("Name" => $row1['Name'], "Value" => $row1['Value'], "ID" => $row['CollegeID']);
}
在您的情况下无关紧要,因为您总是用新的一行覆盖实际的$depts
变量