I'm sure this is simple

A

Anonymous

Guest
I have spent a couple days playing around with this and i can't get the query to work. The code on the bottom that is commented out will insert into the table fine. mysql_error() doesn't produce any info to help. TIA

<?
include("dbconnect.php");

$results = @mysql_query("SELECT * FROM admin");

if (!$result) {
echo '<p>Error performing query: ' . mysql_error() . '</p>';
}

while ($row = mysql_fetch_array($result)) {
echo '<p>' . $row['username'] . '</p>';
}

//mysql_query ("INSERT INTO admin (username, password)
// VALUES ('Tommy', 'Boy')
// ");

?>

Here is what the browser outputs

connected to sever
connected to database
Error performing query:


Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in *********************** on line 13
 
fualker said:
$results = @mysql_query("SELECT * FROM admin");

if (!$result//$results (missing s)//) {
echo '<p>Error performing query: ' . mysql_error() . '</p>';
}

while ($row = mysql_fetch_array($result//$results (missing s)//) )) {
echo '<p>' . $row['username'] . '</p>';
}
 
Back
Top