mysql_query .......... PLEASE HELP

Everytime I run this code,

$dbcon = mysql_connect(“localhost”,“user”,“pass”) or die(“Could not make connection to database”);
mysql_select_db(“my_db”,$dbcon) or die(“Could not select the proper database”);

$rs = mysql_query(“SELECT des FROM picdes WHERE id=’”.$image."’");
echo $image;
echo ("

PIC");
echo $rs;

I got an error saying:

“resource id # 90”

then I added the lines in blue

$dbcon = mysql_connect(“localhost”,“user”,“pass”) or die(“Could not make connection to database”);
mysql_select_db(“my_db”,$dbcon) or die(“Could not select the proper database”);

$rs = mysql_query(“SELECT des FROM picdes WHERE id=’”.$image."’");
$ar = mysql_fetch_object($rs);
echo $image;
echo ("

PIC");
echo $ar;

and now I get the following as the query result:

Object

How do I get the actual data in the table? Help!!

instead of fetch_object use fetch_assoc. Then you can access the data through the column names.

Reference:
http://www.php.net/manual/en/function.m … -assoc.php Note the Expanded Example

tried mysql_fetch_assoc

result is now ‘Array’. :(

Yes that is how it is supposed to be. Did you look at the example? I don’t understand what you don’t get because the example is pretty straigh forward. The first row of the results is returned as an array that you can either loop through or directly call with the key as the column name. If you would like to see a tutorial on the subject go to http://www.codewalkers.com in the tutorials/basics section check out “Creating Dynamic Websites with PHP and MySQL”. Just skip passed the part where they are installing all the software. The tutorial goes over Insertion, Deletion, and Selection of data from the database.

Sponsor our Newsletter | Privacy Policy | Terms of Service