Page 1 of 1

Resource ID no.2

Posted: Tue Jun 03, 2003 6:13 pm
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 :)

Posted: Tue Jun 03, 2003 6:20 pm
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.

Posted: Wed Jun 04, 2003 4:11 am
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 :)