当前位置:Gxlcms > PHP教程 > PHP读取mysql中图片的有关问题

PHP读取mysql中图片的有关问题

时间:2021-07-01 10:21:17 帮助过:20人阅读

PHP读取mysql中图片的问题

// pic_database_output.php By Bleakwind
header( "content-type: image/gif");
$Host = "localhost";
$User = "root";
$Password = "";
$Database = "mycicel";

mysqli_connect($Host,$User,$Password) or die("Could not connect:" . mysqli_error());
mysqli_select_db($Database) or die("Could not select database!");

$sql= "SELECT userbase_head FROM `userbase_tables` WHERE `userbase_id`=1";
$result = mysqli_query($sql) or die("Could not perform query!");
$row = mysqli_fetch_array($result);
echo $row['userbase_head'];
?>

通过mysqli无法获得图片,说的是因其本身有错无法显示


// pic_database_output.php By Bleakwind
header( "content-type: image/gif");
$Host = "localhost";
$User = "root";
$Password = "";
$Database = "mycicel";

mysql_connect($Host,$User,$Password) or die("Could not connect:" . mysql_error());
mysql_select_db($Database) or die("Could not select database!");

$sql= "SELECT userbase_head FROM `userbase_tables` WHERE `userbase_id`=1";
$result = mysql_query($sql) or die("Could not perform query!");
$row = mysql_fetch_array($result);
echo $row['userbase_head'];
?>

这段代码可以成功获取,请教大家这是为什么,要通过mysqli应该如何写 php mysql


------解决方案--------------------
先将header注释掉,看报什么错了。

人气教程排行