0

elective_mgmt データベースの優先順位テーブルからデータを取得しようとしました。ソース コードは以下のとおりです。

<?php
    $connect = mysql_connect("localhost","root","");
    mysql_select_db("elective_mgmt",$connect);
    $result = mysql_query($con,"SELECT * FROM priority");
        echo "<table border='1'>
`<tr>
<th>Name</th>
<th>Roll</th>
<th>Email</th>
<th>Priorityone</th>
<th>Prioritytwo</th>
<th>Prioritythree</th>
</tr>";
while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td>" . $row['Name'] . "</td>";
  echo "<td>" . $row['Roll'] . "</td>";
  echo "<td>" . $row['Email']. "</td>";
  echo "<td>" . $row['Priorityone']."</td>";
  echo "<td" . $row['Prioritytwo']."</td>";
  echo "<td" . $row['Prioritythree']."</td>"; 
  echo "</tr>";
  }
echo "</table>";

mysql_close($con);
?>

 ?>

実行すると、次のように表示されます。

Warning: mysql_query() expects parameter 2 to be resource, string given in C:\xampp\htdocs\Elective_management\admin_view.php on line 5

Warning: mysql_fetch_array() expects parameter 1 to be resource, null given in C:\xampp\htdocs\Elective_management\admin_view.php on line 15
Name    Roll    Email   Priorityone Prioritytwo Prioritythree

Warning: mysql_close() expects parameter 1 to be resource, null given in C:\xampp\htdocs\Elective_management\admin_view.php on line 28
?>

わからなかった。私を助けてください。

4

4 に答える 4

0

パラメータの順序mysql_queryが正しくありません。最初にクエリ、次に接続。

mysql_query("SELECT * FROM priority", $connect);
于 2013-07-11T06:05:41.917 に答える
0

あなたは間違った接続を与えました。このように見えるはずです

 $result = mysql_query("SELECT * FROM priority",$connect );
于 2013-07-11T06:07:02.793 に答える
0

接続したばかりなので、接続変数は必要ありません。入力できるはずです

$result = mysql_query("SELECT * FROM priority");

そしてそれがうまく機能するようにします

于 2013-07-11T06:08:37.253 に答える