Thomas Hutton
Thomas Hutton

Reputation: 803

Only Half Image Retrieved from Blob Being Shown

When I retrieve a blob via PHP it only loads about half the image.

Here's my code:

<?php
require 'dbconnect.php';
$q="SELECT * FROM mtgcards WHERE Name LIKE '%".$_POST['search']."%'";
$r = mysqli_query($dbc, $q);
while ($row = mysqli_fetch_array($r)) {
    echo '<br>'. 'Name: ' . $row['Name'] . ' Mana cost: ' . $row['Mana Cost'] . ' Colour: ' . $row['Colour'] . ' Set: ' . $row['Set'] . ' Ability: ' . $row['Ability']. '<img src="data:image/jpeg;base64,' . base64_encode($row['Image']) . '" width="223" height="311">';
}

mysqli_close($dbc);
?>

Here's what the full picture is and what the picture when I retrieve it comes out as.

enter image description here

Thanks in advance!

Upvotes: 1

Views: 1002

Answers (1)

Funk Forty Niner
Funk Forty Niner

Reputation: 74219

As it seems and was determined in comments, BLOB is too small a column type for the image's (raw) size, therefore you will need to use LONGBLOB.

Reference:

So you will need to alter your column, and resave your data then start over.

Upvotes: 2

Related Questions