Php 在单独的脚本中加载图像blob时出现问题

Php 在单独的脚本中加载图像blob时出现问题,php,Php,我想加载映像,但到目前为止,我能得到的解决方案是加载一个单独的带有db-reconnection的脚本 我有一个init.php文件,它基本上用db连接启动应用程序。 看起来像这样 if(!isset($_SESSION)){ session_start(); } //error_reporting(0); //dont show path name errors when error occurs // include required files require 'datab

我想加载映像,但到目前为止,我能得到的解决方案是加载一个单独的带有db-reconnection的脚本

我有一个init.php文件,它基本上用db连接启动应用程序。 看起来像这样

 if(!isset($_SESSION)){
     session_start();
}
//error_reporting(0); //dont show path name errors when error occurs

//  include required files
require 'databases/connect.php';
我有一行代码,它告诉blob脚本检索图像数据

   <img src="../core/functions/images.php?image_id=<?php echo $responses[$i]['product_id']; ?>" height="150" width="180" alt=""/>
“height=“150”width=“180”alt=”“/>
这是一个问题脚本,它再次重新连接数据库,然后检索图像数据。如果我不重新连接数据库,mysql脚本将失败。对此有什么帮助吗,所以我不需要重新连接数据库

$connect_error = "Sry, we are working on an error, try later";
mysql_connect('localhost','root','') or die($connect_error);
mysql_select_db('SJ3') or die($connect_error);

 if(isset($_GET['image_id'])) {
    $sql = "SELECT imageType,imageData FROM output_images WHERE imageId=" . $_GET['image_id'];
    $result = mysql_query("$sql") or die("<b>Error:</b> Problem on Retrieving Image BLOB<br/>" . mysql_error());
    $row = mysql_fetch_array($result);
    header("Content-type: " . $row["imageType"]);

    echo $row["imageData"];
}
?>
$connect\u error=“Sry,我们正在处理一个错误,请稍后再试”;
mysql\u connect('localhost','root','')或die($connect\u error);
mysql\u选择\u db('SJ3')或die($connect\u error);
如果(isset($\u GET['image\u id'])){
$sql=“选择imageType,imageData FROM output_images,其中imageId=“;
$result=mysql\u query($sql)或die(“错误:检索图像BLOB时出现问题
”。mysql\u Error()); $row=mysql\u fetch\u数组($result); 标题(“内容类型:”.$row[“imageType”]); echo$行[“imageData”]; } ?>
这是一个新页面,它需要一个连接(如果可以的话将被回收),你可以把
require'databases/connect.php';
放在图片中。php当它没有解决问题时,它会重新连接数据库,这是我试图避免的。数据库连接不是持久的,重新连接是你必须做的。