//将图片存进数据库再读出,注意存储图片的字段类型必须为blob
$user=’root’;
$password=’root’;
$db=’test’;
$connect=mysql_connect(‘localhost’,$user,$password);
mysql_set_charset(‘utf8′,$connect);
mysql_select_db($db);
$photo = “0x”.bin2hex(file_get_contents(“./test.jpg”));
$sql=”INSERT INTO `test`.`test` (`photo`) VALUES ($photo);”;//$photo不需要用引号,切记
mysql_query($sql);
//$result=mysql_query(“SELECT *
//FROM `test`
//LIMIT 0 , 30〃);
//$img=mysql_fetch_array($result);
//echo $img['photo'];
?>