I inserted an image into my phpmyadmin database using this:
UPDATE
inventory
SET
IMG = LOAD_FILE('A:/Programs/XAMPP/htdocs/SamsCarLot/images/mercedes-benz.jpg')
WHERE
VIN = 'WDDGF8AB9DR298549';
When I try to echo it onto my webpage I get these very odd looking characters click to view photo
My syntax is correct I'm sure, correct me if it isn't, but I don't know why my image is converting itself from my database to these funky characters.
<?php
$vin = mysqli_real_escape_string($conn, $_GET['VIN']);
$sql = "SELECT * FROM inventory WHERE VIN = '$vin'";
$result = $conn->query($sql);
$stmt = $conn->prepare("SELECT Model FROM inventory WHERE VIN = ?");
$stmt->bind_param("s", $vin);
$stmt->execute();
$stmt->bind_result($model);
$stmt->fetch();
echo "<h1>$model</h1>";
// Loop through all the rows returned by the query, creating a table row for each
while ($result_ar = mysqli_fetch_assoc($result)) {
$img = $result_ar['IMG'];
$year = $result_ar['YEAR'];
$make = $result_ar['Make'];
$model = $result_ar['Model'];
$trim = $result_ar['TRIM'];
$color = $result_ar['EXT_COLOR'];
$interior = $result_ar['INT_COLOR'];
$mileage = $result_ar['MILEAGE'];
$transmission = $result_ar['TRANSMISSION'];
$price = $result_ar['ASKING_PRICE'];
}
echo "<IMG src='$img' width='250'>";
echo "$year $make $model</p>";
echo "<p>Asking Price: $price </p>";
echo "<p>Exeterior Color: $color</p>";
echo "<p>Interior Color: $interior </p>";
$conn->close();
//INSERT INTO images (img) VALUES ('A:/Programs/XAMPP/htdocs/Sam'sCarLot/images/ferrari.jpg')
?>