可能重複時錯誤:
mysql_fetch_array() expects parameter 1 to be resource, boolean given in selectimagesx()和imagesy()創建TUMBNAIL
我想全自動創建頂帖縮略圖。所以我決定調整後與小尺寸的當前圖像使用它作爲TUMBNAIL利用這一點 - resize-class.php類,並寫了這樣的代碼:
// Include the class
include("resize-class.php");
$top_posts = mysql_query("In this query I select top posts - the most viewed posts of the day")
while ($row = mysql_fetch_array($top_posts)){
$post_id = $row['post_id']; // defining the ID of the post as variable
$post_image = $row['post_image']; //defining the image of the post as variable
//save image
$resizeObj = new resize($post_image); // Initialise - load image
$resizeObj -> resizeImage(260, 210, 'exact'); // resizing $post_image with 'exact' option
$resizeObj -> saveImage('images/'.$post_id.'.jpg', 80); // saving thumbnail of $post_image to the storage
}
但在循環返回象這樣的錯誤:
Warning: imagesx() expects parameter 1 to be resource, boolean given in resize-class.php on line 34
Warning: imagesy() expects parameter 1 to be resource, boolean given in resize-class.php on line 35
Warning: imagecopyresampled() expects parameter 2 to be resource, boolean given in resize-class.php on line 77
問題是什麼?
你需要顯示我們的相關代碼'resize :: __ construct()','resize :: resizeImage()'和'resize :: saveImage()'。 – Bojangles 2012-01-29 00:14:26
我已經提到它 - 在我的問題中的類。這裏是http://pastebin.com/mWHek5At – John 2012-01-29 00:15:57
對不起,沒有看到鏈接。 – Bojangles 2012-01-29 00:17:05