So I have a mySQL database with over 800 blob images paired with unique numerical values. My goal is to use a php file to access the images and numbers to display each image on a different page based on the number or "carno".
Ex: pl0x.net/image.php/?carno=500 would display the image from the database with the "carno" sql variable equal to 500
I had this working a week ago with this old code:
<?php
ini_set('display_errors',1);
error_reporting(E_ALL);
$conn = mysql_connect(".....");
if(!$conn)
{
echo mysql_error();
}
$db = mysql_select_db("....", $conn);
if(!$db)
{
echo mysql_error();
}
$carno = $_GET['carno'];
$q = "SELECT carphoto,carphototype FROM carmodelpictures where carno='$carno'";
$r = mysqli_query("$q",$conn);
if($r)
{
$row = mysql_fetch_array($r);
$type = "Content-type: ".$row['carphototype'];
header($type);
echo $row['carphoto'];
}
else
{
echo mysql_error();
}
?>
After an update from my webhost, this code stopped working, so I've been trying to replicate it without error.
Currently I have some code that will display all 885 of my images, but when I right click and select "open image in new tab", the url is just "data:"
<?php
ini_set('display_errors',1);
error_reporting(E_ALL);
$conn = mysqli_connect("......");
if(!$conn)
{
echo mysql_error();
}
$q = "SELECT * FROM carmodelpictures";
$r = mysqli_query($conn, $q);
if($r)
{
while($row=mysqli_fetch_array($r))
{
$result=mysqli_fetch_array($r);
echo '<img src="data:image/jpeg;base64,'.base64_encode( $result['carphoto'] ).'"/>';
}
}
?>
Being very inexperienced with php and html, any ideas or input would be appreciated!