这里我的连接查询问题..我不知道问题出在哪里我的查询是错误还是whatelse但它给出的错误是
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\project\teacher\courses-list.php on line 46
继承人我的代码请修改代码我cudnt找到问题.. :( courses-list.php
<?php
if ($_SESSION["isteacher"])
{
$con=mysql_connect($dbserver,$dbusername,$dbpassword);
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db($dbname, $con);
$result = mysql_query("SELECT courses.id AS cid, courses.title, courses.description, courses.subjects-id, subjects.id AS sid, subjects.subjectname AS sname FROM courses, subjects WHERE (courses.subjects-id==subjects.id)");
echo "<table border='1'> <br />
<tr>
<th>ID:</th>
<th>Course Name</th>
<th>Description</th>
<th>Subject-ID</th>
<th>EDIT</th>
<th>DELETE</th>
</tr>";
while($row = mysql_fetch_array($result)) // this is the error line
{
echo "<tr>";
echo "<td>" . $row['cid'] . "</td>";
echo "<td>" . $row['title'] . "</td>";
echo "<td>" . $row['description'] . "</td>";
echo "<td>" . $row['sname'] . "</td>";
echo "<td><a href='courses-edit.php?id=" . $row['id']."'>EDIT</a></td>";
echo "<td><a href='courses-delete.php?id=" . $row['id']."'>DELETE</a></td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
?>
答案 0 :(得分:1)
这是错误
$result = mysql_query("SELECT courses.id AS cid, courses.title, courses.description, courses.subjects-id, subjects.id AS sid, subjects.subjectname AS sname FROM courses, subjects WHERE (courses.subjects-id==subjects.id)");
应该是
$result = mysql_query("SELECT courses.id AS cid, courses.title, courses.description, courses.subjects-id, subjects.id AS sid, subjects.subjectname AS sname FROM courses, subjects WHERE (courses.subjects-id=subjects.id)");
错误部分是
subjects WHERE (courses.subjects-id==subjects.id)");
here is the error ---------^^--------sould be =