I want to know what method to use to view Images from my MYSQL database using PHP. i know that for basic data it is getString(). what about for images?

well in fact i have never used Blogs
so my answer is going to be just about php
but if you r asking about the process
then u have to stor the images in binary fields in db using fopen and fread or file_get_contents
then to show them back u just have to use the mime type and image size then add some header vars and that will be enough

What would be the code string will it be getMime() @the_traveller

Once again i am still left in the cold with you guys being so unhelpful

Member Avatar for diafol

Dear edensigauke, you have failed to include any information regarding the issue, such as your SQL table, any code that you've tried. The functions that you quote:

getMime() and getString() are not php functions, but probably user-defined functions.

Stefano actually helped you search for 'blob storage', commonly used for images in DBs.
Traveller gave you the process required.

You seem to have done nothing with that help, other than ask for code. This site does not offer free lunches, we attempt to help those that are willing to help themselves.

If you post your code, your SQL table, etc, then I'm sure you'll get a few bites, but simply demanding code, will result in you being ignored.

well Mr Diafol, using php there is a $****['Column Name'] and the like and it is used to retrieve text or numerical numbers...

As for the link i have been there done that and as much as they say they wor, the y do not work on the hosting platform i am using, which is IIS and the Webhosting server i am using Zimonline.... so when you call on an image you get the best ever Computer Giberish ever instead of an image....

here is some code

<?php
                $theSellerDetails = mysql_query("SELECT * FROM sellertable WHERE SellerID='".$theResult['SellerID']."'");       

                while($getDetails=mysql_fetch_array($theSellerDetails))
                {   

                    ?>
                <a href="<?php echo "".$getDetails['SellerProfileLink']; ?>"><img src="<?php echo $getDetails['SellerSearchGetLogo'];?>" height="100" width="100"></a>
    <br>
                        <a href="<?php echo "".$getDetails['SellerProfileLink'];?>">
                    <?php        
                        $theName = $getDetails['SellerUsername'];
                        $_SESSION['searchName'] = $theName;
                        echo $getDetails['SellerUsername']."<br>";
                        echo "  ".$getDetails['SellerAddressA']."<br>";
                        echo " <b> ".$getDetails['SellerAddressB']."</b> ";                   
                    ?>
                    </a>                 <?php                

                }   
                mysql_free_result($theSellerDetails);
            ?>

Here is one way to go about this:

You'll need a php script, e.g."image.php", that will pretent to be a jpg/png or other image file.
So you'll end up with html like this <img src='image.php' />

The code in "image.php" will be something like this:

//VERY IMPORTANT: The first line of code tells your browser that this file will now act like a jpeg file
header("Content-type: image/jpeg");

/*
* Next you get your blob data from your database. 
* You can do this the same way that you normally 
* get a string from the database (possibly getString(), not clear on what that does), 
* or you can do the following.
*/

$db_connection = mysql_connect('localhost', 'mysql_user', 'mysql_password');
$db_results = mysql_query("SELECT image FROM table WHERE id = '123'");
$db_row = mysql_fetch_array($db_results);

//Next, output your image content
echo $db_row[0];

//I havent tested this yet, but it should get you moving in the right direction

Cool work, because the jiberish i get is like serious, but dont you think it will do the same thing????

Sorry "Some-Jackass", but there was no output, it just would show that there should be an image in the area, but it does not show the image.....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.