Jump to content

Help using php to post pic


Qnuts

Recommended Posts

I am creating a site which shows a picture taken from a database.

 

Previous images work fine but now the images i'm adding aren't loading

 

The source for the old ones that work and the new ones that don't is the exact same.

 

This is the code

# <?php
#     // some basic sanity checks
#     if(isset($_GET['image_id']) && is_numeric($_GET['image_id'])) {
#         //connect to the db
#         $link = mysql_connect("localhost", "", "") or die("Could not connect: " . mysql_error());
#  
#         // select our database
#         mysql_select_db("people") or die(mysql_error());
#  
#         // get the image from the db
#         $sql = "SELECT Picture FROM people WHERE ID=" . $_GET['image_id'];
#        
#         // the result of the query
#         $result = mysql_query("$sql") or die("Invalid query: " . mysql_error());
#  
#         // set the header for the image
#         header("Content-type: image/jpeg");
#         echo mysql_result($result, 0);
#  
#         // close the db link
#         mysql_close($link);
#     }
#     else {
#         echo 'Please use a real id number';
#     }
# ?>

 

And the code to display the pic

 

This one doesn't work:

<img style='float:right' width='80px' height='80px' src='image.php?image_id=70' alt='Photo' />

 

This one does

<img style='float:right' width='80px' height='80px' src='image.php?image_id=131' alt='Photo' />

 

 

Any help would be greatly appreciated.

Link to comment
https://forums.phpfreaks.com/topic/190111-help-using-php-to-post-pic/
Share on other sites

You are storing images inside a database?

 

This is not an answer to your question, rather a solution: Dont use databases to store images, they can become corrupt and it is definitely slower, and more cumbersome than using native file storage. It may seem "cool" to put images into a database but trust me its not worth the hassle.

 

-CB-

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.