我已經創建了一個名爲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