I am very new to php and phplots. I am trying to get the basic graph, i am trying out the example given in the manual. I have put the phplot.php file in the same directory where i have created by sample files to try out
The PHP part of the code is as below
trial.php
include"phplot.php";echo"here";?><?phpecho" I have enterted phplot";//require 'phplot.php';$data=array(array('',10),array('',1));$plot=newPHPlot();$plot->SetDataValues($data);$plot->SetTitle('First Test Plot');$plot->DrawGraph();?>
the html part is as follows
img src="trial.php" alt=""
When i access trial2.html from my browser[ have used chrome and internet explorer], all i get is a blank page and text php plot test. Any help will be highly appreciated.
in my apache logs i get the following errors
C:\wamp\www\FOD\report_generation\trial.php on line 35, referer: http://localhost/FOD/report_generation/trial1.php [Mon Aug 05 17:33:09 2013][error][client 127.0.0.1] File does not exist: C:/wamp/www/favicon.ico
First, your plot-producing script trial.php must not send anything at all to the browser except for the image data (which is written by DrawGraph). Browsers will not be able to do anything when they get a mixture of text and graphics from the same HTTP request, and in addition you will get an error from PHP when PHPlot tries to send the image headers after other data was already written. So remove the echo lines from trial2.php. Also don't close and re-open PHP mode with ?> and <?php or you can produce unwanted blank lines (which will interfere with the image data).
Start with that fix, and try again, and let's see what happens next.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
(I am a little confused, as the email feed from the discussion differs a lot from the above post. I guess you editted it after posting, which is OK, just be aware that this doesn't make a lot of sense now. For example, you now say "also my html now has only" with nothing following.)
Your image script trial.php has PHP code so it must start with <?php. It should not exit PHP mode with ?> or try to restart PHP mode, as this will produce unwanted output in the image file. Somthing like this:
trial.php:
<?phprequire'phplot.php';$data=array(array('',10),array('',1));$plot=newPHPlot();$plot->SetDataValues($data);$plot->SetTitle('First Test Plot');$plot->DrawGraph();
Your HTML-producing script needs to have <img src='trial.php'> somewhere in the body, along with the usual HTML document header and body markup.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi
I copied your php code to a file and named it trial.php. So now it has no ?>. Also my html file trial1.htm has only only one line as you mentioned about img src [when i type the whole code, it does not show here. that is why you did not see any thing in the last thread] with the usual html headers. But still when i call trial1.htm, i get no images.
the apache logs say [Tue Aug 06 11:04:43 2013][error][client 127.0.0.1] File does not exist:
My GD info is as follows
pport enabled
GD Version bundled (2.0.34 compatible)
FreeType Support enabled
FreeType Linkage with freetype
FreeType Version 2.4.3
GIF Read Support enabled
GIF Create Support enabled
JPEG Support enabled
libJPEG Version 6b
PNG Support enabled
libPNG Version 1.2.46
WBMP Support enabled
XBM Support enabled
any thing that i am missing? I am using google chrome browser.
On CLI i get
Warning: Cannot modify header information - headers already sent by (output star
ted at C:\wamp\www\FOD\report_generation\trial.php:2) in C:\wamp\www\FOD\report_
generation\phplot.php on line 1858
You almost got it. You just need to remove the blank line at the top of trial.php. The open marker <?php needs to be the very start of the file. (The PHP interpreter starts off in 'copy' mode - copying everything from your script to the output stream. When it hits <?php it switches to PHP mode. Your script, as attached, produces one blank line before starting the code. That blank like is enough to break it - the "headers already sent" error you saw indicates there was unexpected output before PHPlot started sending the image headers.)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi
I am very new to php and phplots. I am trying to get the basic graph, i am trying out the example given in the manual. I have put the phplot.php file in the same directory where i have created by sample files to try out
The PHP part of the code is as below
trial.php
the html part is as follows
img src="trial.php" alt=""
When i access trial2.html from my browser[ have used chrome and internet explorer], all i get is a blank page and text php plot test. Any help will be highly appreciated.
in my apache logs i get the following errors
C:\wamp\www\FOD\report_generation\trial.php on line 35, referer: http://localhost/FOD/report_generation/trial1.php
[Mon Aug 05 17:33:09 2013] [error] [client 127.0.0.1] File does not exist: C:/wamp/www/favicon.ico
in my acess logs i get the following errors
127.0.0.1 - - [05/Aug/2013:17:33:09 +0530] "GET /FOD/report_generation/trial.php HTTP/1.1" 200 2233
127.0.0.1 - - [05/Aug/2013:17:33:09 +0530] "GET /favicon.ico HTTP/1.1" 404 209
Last edit: KGho 2013-08-05
Hi,
First, your plot-producing script trial.php must not send anything at all to the browser except for the image data (which is written by DrawGraph). Browsers will not be able to do anything when they get a mixture of text and graphics from the same HTTP request, and in addition you will get an error from PHP when PHPlot tries to send the image headers after other data was already written. So remove the echo lines from trial2.php. Also don't close and re-open PHP mode with ?> and <?php or you can produce unwanted blank lines (which will interfere with the image data).
Start with that fix, and try again, and let's see what happens next.
Thanks for responding.
i changed the trail to this now
<html>
<head>
</head>
<body>
</body>
</html>
so no <?php and ?>.
also my html now has only
Still I get the same result.
Apache logs say [Mon Aug 05 21:00:23 2013] [error] [client 127.0.0.1] File does not exist: C:/wamp/www/favicon.ico
access logs say
127.0.0.1 - - [05/Aug/2013:21:00:23 +0530] "GET /favicon.ico HTTP/1.1" 404 209
(I am a little confused, as the email feed from the discussion differs a lot from the above post. I guess you editted it after posting, which is OK, just be aware that this doesn't make a lot of sense now. For example, you now say "also my html now has only" with nothing following.)
Your image script trial.php has PHP code so it must start with <?php. It should not exit PHP mode with ?> or try to restart PHP mode, as this will produce unwanted output in the image file. Somthing like this:
trial.php:
Your HTML-producing script needs to have
<img src='trial.php'>
somewhere in the body, along with the usual HTML document header and body markup.Hi
I copied your php code to a file and named it trial.php. So now it has no ?>. Also my html file trial1.htm has only only one line as you mentioned about img src [when i type the whole code, it does not show here. that is why you did not see any thing in the last thread] with the usual html headers. But still when i call trial1.htm, i get no images.
the apache logs say [Tue Aug 06 11:04:43 2013] [error] [client 127.0.0.1] File does not exist:
My GD info is as follows
pport enabled
GD Version bundled (2.0.34 compatible)
FreeType Support enabled
FreeType Linkage with freetype
FreeType Version 2.4.3
GIF Read Support enabled
GIF Create Support enabled
JPEG Support enabled
libJPEG Version 6b
PNG Support enabled
libPNG Version 1.2.46
WBMP Support enabled
XBM Support enabled
any thing that i am missing? I am using google chrome browser.
On CLI i get
Warning: Cannot modify header information - headers already sent by (output star
ted at C:\wamp\www\FOD\report_generation\trial.php:2) in C:\wamp\www\FOD\report_
generation\phplot.php on line 1858
Call Stack:
0.0477 122976 1. {main}() C:\wamp\www\FOD\report_generation\trial.php:
0
0.1527 1718264 2. PHPlot->DrawGraph() C:\wamp\www\FOD\report_generation
\trial.php:8
0.1874 1731216 3. PHPlot->PrintImage() C:\wamp\www\FOD\report_generatio
n\phplot.php:7568
0.2598 1731576 4. header() C:\wamp\www\FOD\report_generation\phplot.php
:1858
ëPNG
→
IHDR ☻X ☺É☻♥ ☼[÷♂ ♀PLTE ╛╛╛ç╬δ♀═3í ¡IDATx£φ▌An█F¶╞q▓27E►hA▀í╦,ï«¿└▌t
┼ Γ╛╦▲ú7hÄÉ←⌠
Last edit: KGho 2013-08-06
i am attaching the files
You almost got it. You just need to remove the blank line at the top of trial.php. The open marker <?php needs to be the very start of the file. (The PHP interpreter starts off in 'copy' mode - copying everything from your script to the output stream. When it hits <?php it switches to PHP mode. Your script, as attached, produces one blank line before starting the code. That blank like is enough to break it - the "headers already sent" error you saw indicates there was unexpected output before PHPlot started sending the image headers.)
WOW ! It worked ! Thanks a billion.