Jump to content

Function name must be string???


Nodral

Recommended Posts

Hi all

 

Please see function below.  the error I get is

Fatal error: Function name must be a string in D:\Documents\AI24\Web\managerReports\functions.php on line 97

and I've no idea why.  I've highlighted line 97, rather than put all prior functions in too.

 

<?php
function drawGraph($ed, $y2007, $y2008, $y2009, $y2010, $y2011, $name){


//Create image size and initiate
$image=imagecreate(750,700);

//define colours

$background=imagecolorallocate($image, 255, 255, 255);
$white = imagecolorallocate($image, 255, 255, 255);
$black = imagecolorallocate($image, 0, 0, 0);
$red = imagecolorallocate($image, 255, 0, 0);
$blue = imagecolorallocate($image, 0, 51, 204);
$green = imagecolorallocate($image, 0, 204, 255);
$pink = imagecolorallocate($image, 204, 0, 255);
$brown = imagecolorallocate($image, 153, 51, 0);

//draw axes
imageline($image, 0, 600, 650, 600, $black);
imageline($image, 100, 10, 100, 700, $black);

//calculate top coordinates

$y2007a=600-($y2007*50);
$y2008a=600-($y2008*50);
$y2009a=600-($y2009*50);
$y2010a=600-($y2010*50);
$y2011a=600-($y2011*50);

//draw recantgles
imagefilledrectangle($image,110,600,210,$y2007a, $red);
imagefilledrectangle($image,210,600,310,$y2008a, $blue);
imagefilledrectangle($image,310,600,410,$y2009a, $green);
imagefilledrectangle($image,410,600,510,$y2010a, $pink);
imagefilledrectangle($image,510,600,610,$y2011a, $brown);

//add x labels

imagefttext($image, 18, 0, 140,650, $black, 'arial.ttf', "2007");
imagefttext($image, 18, 0, 240,650, $black, 'arial.ttf', "2008");
imagefttext($image, 18, 0, 340,650, $black, 'arial.ttf', "2009");
imagefttext($image, 18, 0, 440,650, $black, 'arial.ttf', "2010");
imagefttext($image, 18, 0, 540,650, $black, 'arial.ttf', "2011");

//add values

imagefttext($image, 18, 0, 160, $y2007a-50, $black, 'arial.ttf', "$y2007");
imagefttext($image, 18, 0, 260, $y2008a-50, $black, 'arial.ttf', "$y2008");
imagefttext($image, 18, 0, 360, $y2009a-50, $black, 'arial.ttf', "$y2009");
imagefttext($image, 18, 0, 460, $y2010a-50, $black, 'arial.ttf', "$y2010");
imagefttext($image, 18, 0, 560, $y2011a-50, $black, 'arial.ttf', "$y2011");

//add title
imagefttext($image, 15, 0, 130,25, $black, 'arial.ttf', "Courses Attended per year for $name 2007 to 2011");

//produce image
$filename = "$ed.jpg";
imagejpeg($image, $filename);

//save to TEMP TABLE

//read file
$fp = fopen($filename,'r');
$data = fread($fp, filesize($filename));
$data = addslashes($data);


//insert into table
$sql = "INSERT INTO graphs (ed, image)
	VALUES (
	$ed, '$data')";
mysql_query($sql);

//delete file from server


//line 97
$fclose("$filename");


unlink($filename);

imagedestroy($image);
}

Link to comment
https://forums.phpfreaks.com/topic/252297-function-name-must-be-string/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.