"img src" is used to give the URL of an image. Actually putting the image data inside of the "src" just won't work. Here's what you have to do. Make another script, call it image.php. This script will take an ID value by GET, and display just that image. Here's a sample script, assuming you stored the data as a PNG.
include "connection_with_db";
if(empty($_GET['photoid']) OR !is_numeric($_GET['photoid'])) exit;
header("Content-type: image/png");
$sql = "SELECT data_photo FROM photos WHERE photo_id='".$_GET['photoid']."'";
$line = mysql_fetch_assoc(mysql_query($sql));
echo $line['data_photo'];
Now, you have your earlier script come by and echo out all the names of the images, as well as an "img src" pointing to the above script that will print out the image.
include "connection_with_db";
$sql = "SELECT * FROM photos";
$result = mysql_query($sql);
while($lines = mysql_fetch_array($result, MYSQL_BOTH))
{
echo "<img src=\"images.php?photoid=".$lines['photo_id']."\"> <br />";
echo $lines['name_photo']."<br />";
}
That should work. Let me know how it goes.
By the way - you might want to change your "connection_with_db" file to "connection_with_db.php" or something. Otherwise, someone could come along to your server, type in a request for the connection_with_db file, and see your usernames and passwords and stuff. If it's .php, it will just be executed like PHP, and they'll only see the output - nothing.