Fatal error: Function name must be a string error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nitaish
Forum Newbie
Posts: 1
Joined: Mon Jan 07, 2008 6:27 am

Fatal error: Function name must be a string error

Post by nitaish »

JayBird | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I am facing a problem with a PHP code. It is a code for uploading images and when I try to upload an image, it throws the error 

[b]Fatal error: Function name must be a string error[/b]

The code seems to be written fine. The same code is running fine on another server as confirmed by the programmer. Here is the code for reference.

Code: Select all

<html>
<head>
<title>WELCOME TO SAAJAN SAJNI</title>
<link rel="stylesheet" href="include/style.css" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript">
	function Continue()
	{ 
		window.parent.location.href = "uploadimage.asp?pic=1"
	}
</script>
</head>

<body bgcolor="#FFFFFF" text="#FFFFFF">
<?php
		
		// Configuration
		$uploaddir = "MemberImage";
		//$extension = pathinfo($_FILES['blob']['tmp_name']);
		//$extension = $extension[extension];
		//echo $extension;
		//$FileId = 5;
		$FileId = $_REQUEST['id'];
		$filename = $FileId . ".jpg";
		$uploadedfile = $_FILES['blob']['tmp_name'];
		move_uploaded_file($_FILES['blob']['tmp_name'],$uploaddir.'/'.$filename);
		$uploadfile = $uploaddir.'/'.$filename;
		$imagesize = getimagesize($uploadfile); 
					if ($imagesize[0] > 300) 
					{ 
	?>
<?
						$newwidth = 300; 
						$newheight = ((300 / $imagesize[0]) * $imagesize[1]); 
						//THE RESIZE 
						//find the file extension 
						$image_type = $imagesize[2]; 
						//decide which imagecreate line to use- this is because i allow various types of image files to be uploaded (jpg, png etc) so the code needs to know whether to use imagecreatefromjpeg, imagecreatefromgif etc. If youre only using the one kind of image, you dont need this 
						if ($image_type == '2') 
						{ 
							$source = imagecreatefromjpeg($uploadfile); 
							$create = imagejpeg; 
						} 
						elseif ($image_type == '1') 
						{ 
							$source = imagecreatefromgif($uploadfile); 
							$create = imagegif; 
						} 
						elseif ($image_type == '3') 
						{ 
							$source = imagecreatefrompng($uploadfile); 
							$create = imagepng; 
						} 
						//image create 
						$newimage = imagecreatetruecolor($newwidth, $newheight); 
						imagecopyresampled($newimage, $source, 0, 0, 0, 0, $newwidth, $newheight, $imagesize[0], $imagesize[1]); 
						// Output 
						$create($newimage, $uploadfile, 75); 
					}
					else
					{
						$newwidth = $imagesize[0]; 
						$newheight = $imagesize[1]; 
						//THE RESIZE 
						//find the file extension 
						$image_type = $imagesize[2]; 
						//decide which imagecreate line to use- this is because i allow various types of image files to be uploaded (jpg, png etc) so the code needs to know whether to use imagecreatefromjpeg, imagecreatefromgif etc. If youre only using the one kind of image, you dont need this 
						if ($image_type == '2') 
						{ 
							$source = imagecreatefromjpeg($uploadfile); 
							$create = imagejpeg; 
						} 
						elseif ($image_type == '1') 
						{ 
							$source = imagecreatefromgif($uploadfile); 
							$create = imagegif; 
						} 
						elseif ($image_type == '3') 
						{ 
							$source = imagecreatefrompng($uploadfile); 
							$create = imagepng; 
						} 
						//image create 
						$newimage = imagecreatetruecolor($newwidth, $newheight); 
						imagecopyresampled($newimage, $source, 0, 0, 0, 0, $newwidth, $newheight, $imagesize[0], $imagesize[1]); 
						// Output 
						$create($newimage, $uploadfile, 75);	
					}
					
					$uploaddir = "MemberThumbNail/";
			 		$thumbs_location = $uploaddir.$filename;	
			 		$source = imagecreatefromjpeg($uploadfile); 
				 
					$imagesize = getimagesize($uploadfile); 
					$newwidth = 75; 
					$newheight = 75;
					//((110 / $imagesize[0]) * $imagesize[1]); 
					$newimage = imagecreatetruecolor($newwidth, $newheight);
					imagecopyresampled($newimage, $source, 0, 0, 0, 0, $newwidth, $newheight, $imagesize[0], $imagesize[1]); 
					$create($newimage, $thumbs_location, 75); 
					chmod($uploadfile, 0777);
?>
<br>
<br>
<br>
<br>
<br>
<br>
<table width="90%" border="0" cellspacing="1" cellpadding="3" align="center" class="tablebg">
  <tr valign=top class="tableInnerTr"> 
    <td align=left>
      <div align="center"><b><font color="#000000">Image Uploaded Successfully. 
        Please Confirm Image Upload By Clicking Confirm</font></b></div>
    </td>
  </tr>
  <tr valign=top class="TableInnertr"> 
    <td align=left> 
      <div align="center">
        <input type=button value="  Confirm" onClick="Continue();" class ="submit" name="button">
      </div>
    </td>
  </tr>
</table>
</body>
</html>

Can anybody help me in finding and resolving the error?

Regards
Nitaish


JayBird | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
mcog_esteban
Forum Contributor
Posts: 127
Joined: Tue Dec 30, 2003 3:28 pm

Post by mcog_esteban »

Look here.

Code: Select all

$create($newimage, $uploadfile, 75);
User avatar
Zoxive
Forum Regular
Posts: 974
Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan

Post by Zoxive »

Code: Select all

$create = imagejpeg; 
Change them to strings. Right now it thinks they are constants.

Code: Select all

$create = 'imagejpeg';
For each of your image types. (Jpeg/gif/png)
Post Reply