我已经创建了一个名为movie的数据库,并且有名为test_image(id int autoincrement,name varchar(30),image blob)的表。数据插入与PHP的帮助code.Now我已经显示与下面的代码帮助图片:php + mysql图像幻灯片
<?php
$host="yourhostname";
$user="username";
$pass="password";
$db="movie";
// just so we know it is broken
error_reporting(E_ALL);
//connect to the db
$link = mysql_connect("$host", "$user", "$pass") or die("Could not connect: " . mysql_error());
// select our database
mysql_select_db("$db") or die(mysql_error());
// get the image from the db
$sql = "SELECT image FROM test_image;";
// the result of the query
$result = mysql_query("$sql") or die("Invalid query: " . mysql_error());
// set the header for the image
header("Content-type: image/jpeg");
echo mysql_result($result, 0);
// close the db link
mysql_close($link);
>
,仅显示一个图像 现在如果我?想要在数据库中幻灯片的图像我必须做什么变化?
很多变化。从不再使用'mysql_ *'函数开始。 – hjpotter92 2013-03-19 07:42:23
[**请不要在新代码中使用'mysql_ *'函数**](http://bit.ly/phpmsql)。他们不再被维护[并被正式弃用](https://wiki.php.net/rfc/mysql_deprecation)。看到[**红框**](http://j.mp/Te9zIL)?学习[*准备的语句*](http://j.mp/T9hLWi),并使用[PDO](http://php.net/pdo)或[MySQLi](http://php.net/ mysqli) - [这篇文章](http://j.mp/QEx8IB)将帮助你决定哪个。如果你选择PDO,[这里是一个很好的教程](http://www.brightmeup.info/article.php?a_id=2)。 – 2013-03-19 07:43:02