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
finny
Forum Newbie
Posts: 15 Joined: Mon Apr 24, 2006 7:43 am
Post
by finny » Wed Mar 05, 2008 2:03 pm
HI,
I created a bar chart using a php scipt & the GD Library but I cant get it to print using IE7. Is this an issue with IE7 or is it the way I am calling the php script...
II am calling it using...
Code: Select all
echo '<img src="http://www.site.com/graph/graph1.php" />';
All I get on printouts is a little red x where the GD Library graph should appear. All other images on the page print perfectly.
Thanks
Sekka
Forum Commoner
Posts: 91 Joined: Mon Feb 18, 2008 10:25 am
Location: Huddersfield, West Yorkshire, UK
Post
by Sekka » Wed Mar 05, 2008 2:24 pm
What headers are you sending before you 'print' the image?
finny
Forum Newbie
Posts: 15 Joined: Mon Apr 24, 2006 7:43 am
Post
by finny » Thu Mar 06, 2008 4:34 am
html headers? This is my code below. A print preview in IE7 displays the page with a missing image. Firefox print preview displays the image. Thanks for your help.
Code: Select all
<?php
session_start();
?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF">
<?php
$_SESSION['bin1'] = $bin1;
$_SESSION['bin2'] = $bin2;
$_SESSION['bin3'] = $bin3;
$_SESSION['bin4'] = $bin4;
$_SESSION['bin5'] = $bin5;
$_SESSION['bin6'] = $bin6;
$_SESSION['bin7'] = $bin7;
$_SESSION['bin8'] = $bin8;
$_SESSION['bin9'] = $bin9;
$_SESSION['bin10'] = $bin10;
$_SESSION['bin11'] = $bin11;
$_SESSION['bin12'] = $bin12;
$vartest2 = 116;
$date = date('H:i, jS F');
echo '<p>Data Submitted at: ';
echo $date;
echo '<br />';
echo '<br />';
echo 'Test Number: ' .$testnum.'<br />';
echo 'Spreader Identification: ' .$spreadid.'<br />';
echo 'Test Date: ' .$testdate.'<br />' ;
echo 'Test Material: ' .$testmat.'<br>';
echo 'Spinner Size: ' .$spinsize. '<br>';
echo 'Spinner Speed: ' .$spinspeed. '<br>';
echo 'Bout Width: ' .$boutwidth. '<br>' ;
echo 'Rate: ' .$rate. '<br>' ;
echo 'Number of Runs: ' .$numruns. '<br>' ;
echo 'Direction Spread: ' .$dirspread. '<br>' ;
echo '<br />';
echo 'BIN1: ' .$bin1. "\t" .$binpos1. '<br>' ;
echo 'BIN2: ' .$bin2. "\t" .$binpos2. '<br>' ;
echo 'BIN3: ' .$bin3. "\t" .$binpos3. '<br>' ;
echo 'BIN4: ' .$bin4. "\t" .$binpos4. '<br>' ;
echo 'BIN5: ' .$bin5. "\t" .$binpos5. '<br>' ;
echo 'BIN6: ' .$bin6. "\t" .$binpos6. '<br>' ;
echo 'BIN7: ' .$bin7. "\t" .$binpos7. '<br>' ;
echo 'BIN8: ' .$bin8. "\t" .$binpos8. '<br>' ;
echo 'BIN9: ' .$bin9. "\t" .$binpos9. '<br>' ;
echo 'BIN10: ' .$bin10. "\t" .$binpos10. '<br>' ;
echo 'BIN11: ' .$bin11. "\t" .$binpos11. '<br>' ;
echo 'BIN12: ' .$bin12. "\t" .$binpos12. '<br>' ;
echo '<br />';
echo '<img src="http://www.site.com/graph/graph1.php" />';
echo '<br />';
echo 'Email: ' .$email.'<br />';
// Get n (total)
$numbers = array($bin1,$bin2,$bin3,$bin4,$bin5,$bin6,$bin7,$bin8,$bin9,$bin10,$bin11,$bin12);
$sum_n = array_sum($numbers);
$n = count($numbers);
// Get x^2
$i = 0;
while(count($numbers) > $i) {
$x2[$i] = $numbers[$i] * $numbers[$i];
$i++;
}
// Get total X^2
$total_x2 = array_sum($x2);
// Work out sum x^2/n
$j = $total_x2 / ($n-1);
// $j to 3 s.f
$j3 = round($j, 2);
// Work out mean x
$x_mean = $sum_n / count($numbers);
$x_mean_2 = round($x_mean, 2);
// Work out x_^2
$x_mean = $x_mean * $x_mean;
// Work out sum x^2/n - mean x^2
$f = $j - $x_mean;
$f3 = round($f, 2);
// Work out root of $f
$f = sqrt($f);
$f3 = round($f, 2);
if ($f < 16)
{
echo "<BR><font color=\"#CC0000\"><b>COV = $f3 (ALERT)</b></font>";
}
else
{
echo "<P><font color=\"#006600\"><b>COV = $f3 (OK)</b></font>";
}
echo '<P>Dont forget to print off your test data. ';
$outputstring = $date."\t".$testnum."\t".$spreadid."\t".$date."\t".$testmat
."\t".$spinsize."\t".$spinspeed."\t".$boutwidth."\t".$rate."\t".$numruns."\t".$dirspread."\t".$bin1."\t".$bin2."\t".$bin3."\t".$bin4. "\t".$bin5."\t".$bin6. "\t".$bin7. "\t".$bin8. "\t".$bin9. "\t".$bin10. "\t".$bin11. "\t".$bin12. "\n";
// open file for appending
//$fp = fopen("$DOCUMENT_ROOT/orders.txt", 'a');
$fp = fopen("d:\hshome\acusprea\acuspread.com\orders.txt", 'a');
flock($fp, LOCK_EX);
if (!$fp)
{
echo '<p><strong> Your order could not be processed at this time. '
.'Please try again later.</strong></p></body></html>';
exit;
}
fwrite($fp, $outputstring);
flock($fp, LOCK_UN);
fclose($fp);
echo '<p>Thank you.</p>'; ?>
</body>
</html>
Sekka
Forum Commoner
Posts: 91 Joined: Mon Feb 18, 2008 10:25 am
Location: Huddersfield, West Yorkshire, UK
Post
by Sekka » Thu Mar 06, 2008 8:37 am
This page,
http://www.site.com/graph/graph1.php , generates the image right?
What headers are you sending in this document before you output the image? You will need to do something like the following,
Code: Select all
header ("Content-type: image/jpeg");
imagejpeg ($im);
exit ();