I am trying to display a picture from Mysql, but all the time an error comes out (screen below). There are two files in total.
First articles.php :
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Статьи</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <link rel="stylesheet" href="style.css"> </head> <body> <div class="container"> <h1>Статьи</h1> <a href='admin' id="adm">Панель администратора</a> <p> <h3>Загруженные изображения</h3> <?php mysql_connect ( 'localhost', 'root', '' ); mysql_query( 'utf8_general ci' ); mysql_select_db ( 'blog' ); $query = "SELECT id FROM images"; $res = mysql_query( $query ); while( $img = mysql_fetch_array( $res ) ) { echo '<img src="image.php?id='.$img['id'].'" />'; } ?> </p> <footer> <p>тестовая CRM<br>Copyright © 2015 </p> </footer> </div> </body> </html> And the image.php handler image.php :
<?php // Соединяемся с сервером БД mysql_connect ( 'localhost', 'root', '' ); mysql_query( 'SET NAMES cp1251' ); mysql_select_db ( 'blog' ); if ( isset( $_GET['id'] ) ) { // Здесь $id номер изображения $id = (int)$_GET['id']; if ( $id > 0 ) { $query = "SELECT `content` FROM `images` WHERE `id`=".$id; // Выполняем запрос и получаем файл $res = mysql_query($query); if ( mysql_num_rows( $res ) == 1 ) { $image = mysql_fetch_array($res); // Отсылаем браузеру заголовок, сообщающий о том, что сейчас будет передаваться файл изображения header("Content-type: image/jpeg"); // И передаем сам файл echo $image['content']; } } } ?> Pictures are already available in the database. I keep them in BLOB. 
image.phpfile isimage.phpand why it is not available for the web server. - Dmitriy Simushev