Resource ID no.2

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
necleaners
Forum Newbie
Posts: 2
Joined: Tue Jun 03, 2003 6:13 pm

Resource ID no.2

Post by necleaners »

I am having a problem with a very simple mysql query, basically all i get as an output is resource id #2. I have spent ages on this trying to figure it out, and i would certainly appreciate any help you guys could give me.

This is the code I am using:

Code: Select all

<?php

$db = mysql_connect("localhost", "admin", "tingkyl6");

mysql_select_db("northeastcleaners1",$db);

$main = mysql_query("SELECT maintxt FROM overview",$db);
  
  

print("

<form method='post' action=$PHP_SELF>
<textarea name='pop' rows='10' cols='60'>$main</textarea>
<br><input type='Submit' name='edit' value='Edit'></input>
</form>

");

?>
thankyou very much :)
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

When you mysql_query, you create a thing called a result resource.

To extract information from it, you need to use one of the mysql_fetch_array(), mysql_fetch_assoc(), or mysql_fetch_row(), functions. These return arrays with an element for each column specified in the query.

See php manual for more info.
necleaners
Forum Newbie
Posts: 2
Joined: Tue Jun 03, 2003 6:13 pm

Post by necleaners »

I didn't think I needed an array If I was only trying to get one piece of information from the database- maintxt has only one row.

Thanks, your help is much appreciated :)
Post Reply