Jump to content

Recommended Posts

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

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.