mysql_fetch_array problem
| From: | Zeus | Date: | Sat, 09 Nov 2002 12:28:38 +0000 |
| Subject: | mysql_fetch_array problem | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-16822@lists.php.net to get a copy of this message | ||
I try to display mysql database using fetch_array but there seem to problem,
i m new with PHP and mysql.
I didn't quite sure, what's worng with my codes.i havent include the form
yet.
the error messages:
Warning: mysql_fetch_field(): supplied argument is not a valid MySQL result
resource in c:\apache\htdocs\zeus\shoutbox.php on line 17
code in shoutbox.php:
<?PHP
mysql_connect('localhost', 'zeus', 'pass') or die
("deadconnect");
mysql_select_db('zeussama_db') or die ("no db");
if($submit)
{
$time=date("h:ia d/j/y");
$result=mysql_query("INSERT INTO shoutbox (id,name,message,time)","values
('NULL','$name','$message','$time')");
}
?>
<?php
$result = mysql_query("SELECT * FROM shoutbox BY ID desc LIMIT 5");
while($r=mysql_fetch_field($result))
{
$time=$r["time"];
$id=$r["id"];
$message=$r["message"];
$name=$r["name"];
echo "$time <br>";
echo "$name <br>";
echo "$message <br>";
}
?>
================================
:.zeus:.
http://www.redrival.com/zeussama