Trying to retrieve a value from Mysql db

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
funkyapache
Forum Newbie
Posts: 11
Joined: Tue Mar 24, 2009 11:19 am

Trying to retrieve a value from Mysql db

Post 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.
Mark Baker
Forum Regular
Posts: 710
Joined: Thu Oct 30, 2008 6:24 pm

Re: Trying to retrieve a value from Mysql db

Post 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
Post Reply