首页 >后端开发 >php教程 > PHP读取mysql中图片的有关问题

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

WBOY
WBOY原创
2016-06-13 12:56:56830浏览

PHP读取mysql中图片的问题

<?php<br />
// pic_database_output.php By Bleakwind<br />
header( "content-type: image/gif");<br />
$Host = "localhost";<br />
$User = "root";<br />
$Password = "";<br />
$Database = "mycicel";<br />
<br />
mysqli_connect($Host,$User,$Password) or die("Could not connect:" . mysqli_error());<br />
mysqli_select_db($Database) or die("Could not select database!");<br />
<br />
$sql= "SELECT userbase_head FROM `userbase_tables` WHERE `userbase_id`=1";<br />
$result = mysqli_query($sql) or die("Could not perform query!");<br />
$row = mysqli_fetch_array($result);<br />
echo $row['userbase_head'];<br />
?><br />

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

<?php<br />
// pic_database_output.php By Bleakwind<br />
header( "content-type: image/gif");<br />
$Host = "localhost";<br />
$User = "root";<br />
$Password = "";<br />
$Database = "mycicel";<br />
<br />
mysql_connect($Host,$User,$Password) or die("Could not connect:" . mysql_error());<br />
mysql_select_db($Database) or die("Could not select database!");<br />
<br />
$sql= "SELECT userbase_head FROM `userbase_tables` WHERE `userbase_id`=1";<br />
$result = mysql_query($sql) or die("Could not perform query!");<br />
$row = mysql_fetch_array($result);<br />
echo $row['userbase_head'];<br />
?><br />

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

php mysql
------解决方案--------------------
先将header注释掉,看报什么错了。
声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn