So I am setting up a site, and need some help with the members list. For some odd reason, I get the error:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/USERNAME/alpha/members.php on line 36
Although, I didn't set this up any different than my other lists. Here is the code.
Any help is greatly appreciated.PHP Code:<?php
// Register your Members session
session_start();
// Connect to the Database
$host="localhost"; // Host name
$dbusername="CENSORED"; // Mysql username
$dbpassword="CENSORED"; // Mysql password
$db_name="CENSORED"; // Database name
$tbl_name="members"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "$dbusername", "$dbpassword")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$sql="SELECT * FROM $tbl_name ORDER BY id DESC";
// OREDER BY id DESC is order result by descending
$result=mysql_query($sql);
?>
<!-- Call the Header -->
<?php
include('include/header.php');
?>
<!-- Call the Navigation -->
<?php
include('include/navigation.php');
?>
<div class="main">
<h2>Members List</h2>
<table width="100%" border="0" align="center" cellpadding="3" cellspacing="1">
<?php
// Loop results
while($rows=mysql_fetch_array($result)){
?>
<tr>
<td><? echo $rows['username']; ?></td>
</tr>
<?php
// Exit looping and close connection
}
mysql_close();
?>
</table>
</div>
<!-- Call the Sidebar -->
<?php
include('include/sidebar.php');
?>
<!-- Call the Footer -->
<?php
include('include/footer.php');
?>![]()



Reply With Quote

Bookmarks