Thread: Php
View Single Post
Old 05-13-2009, 01:19 PM   #3 (permalink)
murdocsvan
murdocsvan's Avatar
 
Ultra Techie

Join Date: Jun 2007

Location: Surrey, UK

Posts: 849

murdocsvan is on a distinguished road

Default Re: Php

Okay here is my code:

PHP Code:
<?php

session_start
();

//Check user is logged in in first place
if(!isset($_SESSION['user']))
    {
    
header("location:******");
    }

//Stores mysql login details
$host="localhost"// Host name 
$sql_username="*****"// Mysql username 
$sql_password="*****"// Mysql password 
$db_name="*****"// Database name 
$tbl_name="admin"// Table name 

//mysql Connect variable
$con mysql_connect("$host","$sql_username","$sql_password");

//Query to retrieve information
$query "SELECT * FROM admin";
$result mysql_query($query,$con);

echo 
"<table border='1'>";
echo 
"<td><th>Username</th></tr>";
echo 
'<form action="user_delete.php" method="post">';
// keeps getting the next row until there are no more to get
while($row mysql_fetch_array($result))
    {
    
// Print out the contents of each row into a table
    
echo "<tr><td>";
    echo 
$row['id'];
    echo 
"</td></tr>";
    echo 
"<tr><td>"
    echo 
$row['username'];
    echo 
"</td><td>";
    echo 
'<input type="button" value="" />';
    echo 
"</tr></td>";
    } 

echo 
"</form></table>";
?>
But for some reason it returns an error on the line:

PHP Code:
while($row mysql_fetch_array($result)) 
Quote:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/vmrgjdq/public_html/test/users.php on line 29
Can anyone help?

Thanks.
__________________


Last edited by murdocsvan; 05-13-2009 at 01:23 PM.
murdocsvan is offline