Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> phplot headers already sent..., problem w klasie phplot
pit501
post
Post #1





Grupa: Zarejestrowani
Postów: 5
Pomógł: 0
Dołączył: 2.11.2005

Ostrzeżenie: (0%)
-----


Mam problem z wyswietlaniem wykresów w klasie phplot ale tylko wtedy jeżeli prócz danego wykresu maja zostać wyświetlone jakies wartosci ,przytaczam przykład kodu:
  1. <?php
  2.  
  3. for ($i = 0; $i < 10; $i++)
  4. {
  5. $data[$i] = array("200" . $i, rand());
  6. //echo 'Klucz = ' . $data[$i][0] . '<br>Wartosc = ' . $data[$i][1] . '<br>';<-o tym mowa
  7. }
  8.  
  9.  
  10.  
  11. function plot($data)/////////////////////////////////////////////////////
  12. {
  13. //Include the code
  14. include("../phplot.php");
  15.  
  16. //Define the object
  17. $graph = new PHPlot(600,500);
  18.  
  19. $graph->SetDataValues($data);
  20.  
  21. $graph->SetPlotType("bars");
  22.  
  23. //Draw it
  24. $graph->DrawGraph();
  25. }//////////////////////////////////////////////////////////////////////////
  26.  
  27. plot($data);
  28.  
  29.  
  30.  
  31. ?>


chodzi o drugą linijke w petli for jak jest za znakami komentarza jest wszystko ok
a to jest wyrzucane:

Klucz = 2000
Wartosc = 16177
Klucz = 2001
Wartosc = 1558
Klucz = 2002
Wartosc = 31639
Klucz = 2003
Wartosc = 20868
Klucz = 2004
Wartosc = 7533
Klucz = 2005
Wartosc = 28066
Klucz = 2006
Wartosc = 14899
Klucz = 2007
Wartosc = 496
Klucz = 2008
Wartosc = 9065
Klucz = 2009
Wartosc = 16878

Warning: Cannot modify header information - headers already sent by (output started at c:\usr\apache\httpd\html\examples\p1.php:6) in c:\usr\apache\httpd\html\phplot.php on line 1090

Warning: Cannot modify header information - headers already sent by (output started at c:\usr\apache\httpd\html\examples\p1.php:6) in c:\usr\apache\httpd\html\phplot.php on line 1091

Warning: Cannot modify header information - headers already sent by (output started at c:\usr\apache\httpd\html\examples\p1.php:6) in c:\usr\apache\httpd\html\phplot.php on line 1092

Warning: Cannot modify header information - headers already sent by (output started at c:\usr\apache\httpd\html\examples\p1.php:6) in c:\usr\apache\httpd\html\phplot.php on line 1093

Warning: Cannot modify header information - headers already sent by (output started at c:\usr\apache\httpd\html\examples\p1.php:6) in c:\usr\apache\httpd\html\phplot.php on line 1099
�PNG 

i jakies krzaki... (IMG:http://forum.php.pl/style_emoticons/default/worriedsmiley.gif) (IMG:http://forum.php.pl/style_emoticons/default/worriedsmiley.gif) (IMG:http://forum.php.pl/style_emoticons/default/worriedsmiley.gif) (IMG:http://forum.php.pl/style_emoticons/default/worriedsmiley.gif)
Go to the top of the page
+Quote Post
dr_bonzo
post
Post #2





Grupa: Przyjaciele php.pl
Postów: 5 724
Pomógł: 259
Dołączył: 13.04.2004
Skąd: N/A

Ostrzeżenie: (0%)
-----


phpplot wypluwa JPEGa (z tego co widze), wysyla odpowiednie naglowki (headers, za pomoca header()) a ty wczesniej wysylasz dane (Klucz = 2000, Wartosc = 16177, itd) -- czyli mieszasz text z plikiem graficznym.

Utorz inny plik, ktory wyswietli te dane, i zawiera html z tagiem <img src="wygeneruj_wykres_za_pomoca_phpplot.php" .... />.
W wygeneruj_wykres_za_pomoca_phpplot.php generujesz tylko graf za pomoca phpplot i wyswietlasz go.
Go to the top of the page
+Quote Post
pit501
post
Post #3





Grupa: Zarejestrowani
Postów: 5
Pomógł: 0
Dołączył: 2.11.2005

Ostrzeżenie: (0%)
-----


czy miałoby to wyglądać dosłownie następująco:
plik p1.php :
  1. <?php
  2.  
  3. for ($i = 0; $i < 10; $i++)
  4. {
  5. $data[$i] = array("200" . $i, rand());
  6.  
  7. }
  8.  
  9.  
  10. function plot($data)/////////////////////////////////////////////////////
  11. {
  12. //Include the code
  13. include("../phplot.php");
  14.  
  15. //Define the object
  16. $graph = new PHPlot(600,500);
  17.  
  18. $graph->SetDataValues($data);
  19.  
  20. $graph->SetPlotType("bars");
  21.  
  22. //Draw it
  23. $graph->DrawGraph();
  24. }//////////////////////////////////////////////////////////////////////////
  25.  
  26. plot($data);
  27.  
  28. ?>


i plik p2.php :
  1. <?php
  2.  
  3. include("./p1.php")
  4.  
  5. for ($i = 0; $i < 10; $i++)
  6. {
  7. echo 'Klucz = ' . $data[$i][0] . '<br>Wartosc = ' . $data[$i][1] . '<br>';
  8. }
  9.  
  10.  
  11.  <img src="p1.php" .... />
  12.  
  13. ?>


i uruchamiam p2.php (IMG:http://forum.php.pl/style_emoticons/default/questionmark.gif) ?
Go to the top of the page
+Quote Post
dr_bonzo
post
Post #4





Grupa: Przyjaciele php.pl
Postów: 5 724
Pomógł: 259
Dołączył: 13.04.2004
Skąd: N/A

Ostrzeżenie: (0%)
-----


Dokladnie, wystarczylo sprawdzic.
Go to the top of the page
+Quote Post
pit501
post
Post #5





Grupa: Zarejestrowani
Postów: 5
Pomógł: 0
Dołączył: 2.11.2005

Ostrzeżenie: (0%)
-----


no właśnie twierdzi że błąd w tym
  1. <?php
  2.  
  3. <img src="p1.php" .... />
  4.  
  5. ?>
Go to the top of the page
+Quote Post
dr_bonzo
post
Post #6





Grupa: Przyjaciele php.pl
Postów: 5 724
Pomógł: 259
Dołączył: 13.04.2004
Skąd: N/A

Ostrzeżenie: (0%)
-----


Pomysl troche (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)

Kod html umieszczasz wewnatrz tagow <?php ... ?>, umieszc <img / > poza nimi.
Go to the top of the page
+Quote Post
pit501
post
Post #7





Grupa: Zarejestrowani
Postów: 5
Pomógł: 0
Dołączył: 2.11.2005

Ostrzeżenie: (0%)
-----


heh ale jestem lamerem (IMG:http://forum.php.pl/style_emoticons/default/guitar.gif) (IMG:http://forum.php.pl/style_emoticons/default/guitar.gif) (IMG:http://forum.php.pl/style_emoticons/default/guitar.gif) (IMG:http://forum.php.pl/style_emoticons/default/guitar.gif) thx
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 1.01.2026 - 06:23