我有一个使用 imagecreatefromjpeg 的 PHP 脚本(如下),它可以工作。然后我添加了几个 mysql 语句,它不再起作用(我看到损坏的图像图标)。
如何混合 imagecreatefromjpeg 并与 mysql 查询相关。谢谢!
<?php
//Report any errors
ini_set ("display_errors", "1");
error_reporting(E_ALL);
$user="root";
$password="pw";
$database="piwigo";
//Adding these two lines breaks the image:
//mysql_connect(localhost,$user,$password);
//@mysql_select_db($database) or die( "Unable to select database");
$current_image = imagecreatefromjpeg("sample.jpg");
// place code for saving the montage image as a file or outputting to the
// browser here.
header("Content-type: image/jpeg");
imagejpeg($current_image);
imagedestroy($current_image);
mysql_close();
?>