The page shows as follows:
Manage Users
Warning: mysql_num_fields(): supplied argument is not a valid MySQL result resource in C:\wamp\www\test\manage.php on line 15
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in C:\wamp\www\test\manage.php on line 22
I cannot figure out why it is doing this
Here is the code for the page:
<?php
// Connects to your Database
include("/../../wamp/www/test/includes/db_connect.php");
// checks if user is logged in
require("/../../wamp/www/test/includes/userauth.php");
echo "<h1>Manage Users</h1>";
$query="select * from users";
$result="mysql_query($query)";
echo "<table border=1>";
echo "<tr>";
for($i=0;$i<mysql_num_fields($result);$i++)
{
echo "<th>";
echo mysql_field_name($result, $i);
echo "</th>";
}
while($row=mysql_fetch_row($result))
{
echo "<tr>";
for($j=0;$j<$i;$j++)
{
echo "<td>";
echo $row[$j];
echo "</td>";
}
echo "</tr>";
}
echo "</tr>";
echo "</table>";
?>
and here is db_connect.php:
<?php
mysql_connect("localhost", "snypeZ", "*****") or die("Could not connect to MySQL server.");
mysql_select_db("test") or die("Could not select database.");
?>
and here is userauth.php:
<?php
//checks cookies to make sure they are logged in
if(isset($_COOKIE['ID_my_site']))
{
$username = $_COOKIE['ID_my_site'];
$pass = $_COOKIE['Key_my_site'];
$check = mysql_query("SELECT * FROM users WHERE user_name = '$username'")or die(mysql_error());
while($info = mysql_fetch_array( $check ))
{
//if the cookie has the wrong password, they are taken to the login page
if ($pass != $info['user_password'])
{ header("Location: login.php");
}
}
}
if(!isset($_COOKIE['ID_my_site'])){
echo "You must be logged in to see this page.<br>
<a href='login.php>Login</a>";
exit;
}
?>