0

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?

5
Contributors
9
Replies
11
Views
6 Years
Discussion Span
Last Post by edensigauke
0

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

2

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.

0

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);
            ?>
0

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

Edited by Some-Jackass

0

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

0

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.....

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.