Webbie Webbie - 1 year ago 76
PHP Question

PHP Display all images from DB in a img tagg - PDO

Im trying to display alla images in a

from the db but i am only getting a broken image!
I am storing the ['tmp_name'] as LONGBLOB and the ['name'] as type in my tabel.

$query = $this->connection->prepare("SELECT * FROM images");

$row = $query->fetchAll();

foreach($row as $img){
echo "<pre>";var_dump($img['name']);"</pre>";

echo "<img src=".$img["name"].">";

//header("Content-type: ".$row['type']);
print $row['name'];

Should i use ['tmp_name'] or ['name'] in the

Answer Source

<img src=""> should include the full server path where your image is successfully uploaded. Also should include the image extension as well (.jpg, .png, .gif). should look like similar to following.

<img src="http://ichef.bbci.co.uk/images/ic/160xn/p0306tt8.png">

Easiest way is to check the source code of page and see if you get complete / correct path to the image. If not, check/change your code for missing part.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download