Re: cant view image from database

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 12 Feb 2015 at 21:58, hadi <almarzuki2011@xxxxxxxxxxx> wrote: 

> Hi Tul,
>
> I did exactly what you suggest me.

No you didn't.

> showimage1.php
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
> "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd";>
> <html xmlns="http://www.w3.org/1999/xhtml";>
> <head>
>  <title>dispaly image</title>
>  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
> </head>
>
> <body>

Remove all the above html from showimage1.php - all of it. showimage1.php should start with the <?php line that follows here. You must NOT output anything before the header() below. The html above is "output".

> <?php error_reporting(E_ALL); ini_set('display_errors', 1);
>
> $servername = "localhost";
> $username = "recorduser";
> $password = "password123";
> $database = "record";
>
> // Create connection
> $conn = mysqli_connect($servername, $username, $password, $database);
> // Check connection
> if (!$conn) {
>    die("Connection failed: " . mysqli_connect_error());
> }
>
> $sql = "SELECT * FROM picture";
> $result = mysqli_query($conn, $sql);
>
> header("Content-type: image/jpeg");
> $row = mysqli_fetch_array($result);
> $img = $row["image"];
>
>
> echo $img;

And you don't need the html after here either.

--
Cheers  --  Tim

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux