Re: Resource id #2
| From: | DL Neil | Date: | Sun, 28 Oct 2001 14:55:57 +0000 |
| Subject: | Re: Resource id #2 | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-13782@lists.php.net to get a copy of this message | ||
I am trying to select a message from a table in a database. the message will will be in column
'msg' and will be
in same row as id='0'.
I need that msg put to the screen. With the code below I get the error: Resource id #2
Can someone please explain how I can fix this..
Thankyou in advance.
<?
$msgcre = "SELECT msg FROM creators WHERE id='0'";
$msg = mysql_query($msgcre);
echo "<FONT color='#000000' style='font-size: 10pt; font-weight:
bold'>$msg</font>";
?>
Andrew,
Although the assignment statement looks as though the LHS (left-hand side) should contain the result
of the
query, it does not (as you have discovered). Instead of being an integer or string, it is something
called a
'resource'. You have already 'met' a resource in connection with the db connect
process. After issuing a query,
you must then use one of the mysql_fetch_... functions to extract the data, one field, or one row at
a time,
from the 'resource'. Please check out the manual at http://uk2.php.net/manual/en/ref.mysql.php.
Also you might
consider working through one of the many excellent texts and/or online articles discussing the
PHP/MySQL
combination.
Regards,
=dn