richiejones24 Posted March 8, 2012 Share Posted March 8, 2012 I have a script which creates a Thumbnail image if one does not exists, the problem is i keep getting this error: Catchable fatal error: Object of class SimpleImage could not be converted to string in /homepages/22/d378569747/htdocs/scripts/primary_image.php on line 21 i have checked the logs and i think its a read error because the the image is already in use by the server if i remove (!file_exists("$root/thumnail_user_images/$image")) the script work fine, is there anyway to stop this error occuring? <?php //header('Content-Type: image/jpeg'); $root = $_SERVER['DOCUMENT_ROOT']; require("$root/include/mysqldb.php"); //mysql login details require("$root/include/mysql_connect.php"); //mysql connect $uin = $_GET['uin']; $result = mysql_query("SELECT * FROM Reg_Profile_images WHERE UIN='$uin' AND `primary` = '1' LIMIT 1"); while($row = mysql_fetch_array( $result )) { $image = $row[2]; if (!file_exists("$root/thumnail_user_images/$image")) { require("$root/include/image_resizing_function.php"); //create image $image = new SimpleImage(); $image->load("$root/raw_user_images/$image"); $image->resizeToWidth(250); $image->save("$root/thumnail_user_images/$image"); $image->output(); } else { readfile("$root/thumnail_user_images/$image"); } } //End Image file ?> Link to comment https://forums.phpfreaks.com/topic/258555-read-file-error/ Share on other sites More sharing options...
PFMaBiSmAd Posted March 8, 2012 Share Posted March 8, 2012 You need to pick a different name for the instance of your class. You are already using $image as the name of the image in $image = $row[2]; When you use $image = new SimpleImage();, you are overwriting the image name, but you are still trying to use $image as though it is the image name. The error occurs because $image now contain an instance of your class. Link to comment https://forums.phpfreaks.com/topic/258555-read-file-error/#findComment-1325358 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.