Home  >  Article  >  Backend Development  >  PHP读取mysql中图片的有关问题

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

WBOY
WBOYOriginal
2016-06-13 12:56:56813browse

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注释掉,看报什么错了。
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn