mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\work\work6.php on line 26 ช่วยด้วยรับ จนปัญยาล่ะ
<body>
<?php
$con = mysql_connect("localhost","root","1234");
$avsalary=0;
$count =0;
$dbName="peple";
$charset = "SET character_set_results=utf8";
mysql_query($charset)or die('invalid query :'.mysql_error());
mysql_select_db($dbName,$con)or die("ไม่สามารถเข้าใช้ฐานข้อมูลได้");
$key=$_POST['txtSearch'];
echo $key;
$query="SELECT staff.staffId, staff.name, staff.lastname,department.depName,staff.age,staff.salary,staff.gender
FROM staff, department
WHERE staff.departmentId = department.departmaentId";
$result=mysql_query($query,$con);
echo "<table border=\"2\"align=\"center\">
<tr><td>StaffID</td></td><td>Name</td><td>LastName</td><td>Gender</td><td>Department</td><td>Age</td><td>Salary</td></tr>";
while($row=mysql_fetch_array($result))
{
echo "<tr><td>$row[staffId]</td><td>$row[name]</td><td>$row[lastname]</td><td>$row[gender]</td><td>$row[depName]</td><td>$row[age]</td><td>$row[salary]</td></tr>";
if($row[gender] == 'M')
{
$count +=1;
}
}
echo "</table>";
echo $count;
mysql_close($con);
?>
</body>
</html>
มันขึ้นว่า
mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\work\work6.php on line 26
ช่วยที่ครับTag : PHP
Date :
2012-03-05 11:13:19
By :
aod
View :
1021
Reply :
2
ใส่
$result=mysql_query($query,$con) or die(mysql_error());
แทน
$result=mysql_query($query,$con);
จะได้เห็นว่า error จริง คือ อะไรนะครับ
Date :
2012-03-05 11:16:30
By :
ikikkok
PlaKriMขอบคุนมากครับ
Date :
2012-03-05 11:25:08
By :
aod
Load balance : Server 03