-3

I'm trying to display info from all the users in the data base and it keeps giving me this error

Warning: mysql_fetch_assoc() expects parameter 1 to be resource, string given in /home/killerdu/public_html/userlist.php on line 30

Line 30

while($people=mysql_fetch_assoc($people_list)){

<?php
include 'core/int.php';
include 'includes/head.php';
include 'head.php';
include 'includes/body.php';
include 'body.php';

$people_list="SELECT * FROM users";

$people=mysql_query($people_list);

?>
<html>
<head>
</head>
<body>
<pre>
<table class="table table-bordered">
      <thead>
        <tr>
          <th>ID</th>
          <th>Username</th>
          <th>Email</th>
        </tr>

      <?php

     while($people=mysql_fetch_assoc($people_list)){ 
     echo "<tr>";
          echo "<td>". $people_list['user_id']."</td>";
          echo "<td>". $people_list['username']."</td>";
           echo "<td>". $people_list['email']."</td>";
        echo "</tr>";     
     }

      ?>
      </thead>
      </pre>
</body>
</html>

2 Answers2

3

As requested by the OP, comment to answer:

You mixed up your variables for while($people=mysql_fetch_assoc($people_list)) switch them. while($people_list=mysql_fetch_assoc($people))

Funk Forty Niner
  • 74,372
  • 15
  • 66
  • 132
2

You used $people=mysql_query($people_list);

So load it inside:

while($row=mysql_fetch_assoc($people)) {
                             // ^ load $people, the resource, not $people_list the string

You loaded the query string instead of the resource.

Kevin
  • 41,329
  • 12
  • 52
  • 68