Create image from included PHP file -


i create image included php file, there error of undefined variable:

index.php

<?php // servers , domains $sersel = 'select * servers'; $serreq = $connexion->query($sersel); $serres = $serreq->fetchall(); $totalser = count($serres);  foreach($serres $serv) {  $s_global_size  = $serv['s_global_size']; $s_used_size    = $serv['s_used_size']; $s_creation     = $serv['s_creation']; $s_expiry       = $serv['s_expiry'];  $diskspace = ($e_name == 'domain')  ?   '-'  : format_bytes($s_global_size);  echo $diskspace;  $diskusage = ($e_name == 'domain')  ?   '-'  : format_bytes($s_used_size);  echo $diskusage;  $s_left_size = ($s_global_size - $s_used_size); $sleftsize = ($e_name == 'domain')  ?   '-'  : format_bytes($s_left_size); echo $sleftsize;  }   echo '<img src="idara/statistics/webdata_circle.php">'; 

?>

webdata_circle.php

<?php // create image $image = imagecreatetruecolor(180, 180);  $usageperc = ($diskusage * 360)/$diskspace;  // allocate colors $red = imagecolorallocate($image, 192, 0, 0); $red1 = imagecolorallocate($image, 192, 20, 0); $green = imagecolorallocate($image, 0, 133 ,62); $green1 = imagecolorallocate($image, 0, 140 ,62); $trans = imagecolorallocate($image, 0, 0, 0); // transparent background  // make background transparent imagecolortransparent($image, $trans);   imagefilledarc($image, 80, 80, 150, 150, 0, 360, $red, img_arc_pie); imagefilledarc($image, 80, 80, 150, 150, 0, $usageperc, $green, img_arc_pie);  // flush image header('content-type: image/png'); imagepng($image); imagedestroy($image); ?> 

the error returned is:

 php notice:  undefined variable: diskusage in webdata_circle.php on line 8  php notice:  undefined variable: diskspace in webdata_circle.php on line 8  php warning:  division 0 in webdata_circle.php on line 8 

thanks in advance

nb: full code, hope help

you need add following lines webdata_circle.php, on 2nd line:

$diskpath = dirname(__file__);  $diskusage  = disk_total_space ($diskpath);  $diskusage  = disk_free_space ($diskpath);  

Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

qt - How to embed QML toolbar and menubar into QMainWindow -