Page 1 of 1

Trying to retrieve a value from Mysql db

Posted: Thu Mar 26, 2009 4:48 am
by funkyapache
Hi

I have a table in mysql called tbl_picture_link which stores a url string to some pictures not I would like to retieve the string and place <img> around it.

This is the function I have

Code: Select all

function get_image($image_id){
    //finds and displays the selected image
 
        global $connection;
 
        $query = "SELECT    *
 
                  FROM tbl_picture_link
                  where picture_link_id = {$image_id} 
 
                  LIMIT 1";
 
        $picture_set = mysql_query($query, $connection);
 
        confirm_query($picture_set);
 
        echo "<img scr=\"" . $picture_set['picture_link_href'] . "\">" . $query."<br />";
 
    }
I'm not getting an errors with connection to my db all that its echoed is an img place holder the $query value which is a value sql statement because I copied the output and ran it in phpmyadmin and it returned some the result I was expecting.

Any ideas what could be wrong.

Re: Trying to retrieve a value from Mysql db

Posted: Thu Mar 26, 2009 5:28 am
by Mark Baker
$picture_set isn't an array, it's a resource.

I've no idea what confirm_query() does, but you need to use mysql_fetch_assoc()/mysql_fetch_array()/mysql_fetch_row() to read the actual returned record from the $picture_set resource