Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [MySQL][PHP]Cannot add header information - headers already sent - nie pomaga ob_start()
Michał90
post
Post #1





Grupa: Zarejestrowani
Postów: 267
Pomógł: 0
Dołączył: 16.05.2007

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


Witam,
Dodałem sobie taki kod do mojej strony:
  1. <head>
  2. <link rel="stylesheet" href="style.css" type="text/css" />
  3. <link media="screen" rel="stylesheet" type="text/css" href="st.css" />
  4. <script type="text/javascript" src="jquery.js"></script>
  5. <script type="text/javascript">
  6. <? if(empty($_COOKIE['zablokuj'])){ ?>
  7.  
  8. $(window).load(function() {
  9. $.prompt('<a href="http://adres.pl"><img src="http://adres.pl/adres.jpg" border="0"/></a>',{ overlayspeed: 2 });
  10. });
  11. <? setcookie("zablokuj", 1, time()+(60*60*1)); } ?>
  12. </script>
  13. </head>


I w kodzie strony wyświetla mi się taki błąd:

  1. Warning: Cannot modify header information - headers already sent by (output started at /home/xxx/domains/adres.pl/public_html/index.php:7) in <b>/home/xxx/domains/adres.pl/public_html/index.php</b> on line <b>20</b><br />


Szukałem w google i trafiłem na http://phpedia.pl/wiki/Cannot_add_header_i...rs_already_sent

A więc dodałem
  1. i


Kod wyglądał tak:

  1. <head>
  2. <link rel="stylesheet" href="style.css" type="text/css" />
  3. <link media="screen" rel="stylesheet" type="text/css" href="st.css" />
  4. <script type="text/javascript" src="jquery.js"></script>
  5. <script type="text/javascript">
  6. <? ob_start(); if(empty($_COOKIE['zablokuj'])){ ?>
  7.  
  8. $(window).load(function() {
  9. $.prompt('<a href="http://adres.pl"><img src="http://adres.pl/adres.jpg" border="0"/></a>',{ overlayspeed: 2 });
  10. });
  11. <? setcookie("zablokuj", 1, time()+(60*60*1)); } ob_end_flush(); ?>
  12. </script>
  13. </head>


Ale nie pomogło i problem wyświetla się dalej w kodzie strony, a okienko nie wyskakuje sad.gif

Jak zrobić żeby działało ?

Pozdrawiam
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 2)
Fifi209
post
Post #2





Grupa: Zarejestrowani
Postów: 4 655
Pomógł: 556
Dołączył: 17.03.2009
Skąd: Katowice

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


Bo to ob_start() ma być przed html ! Było setki razy na forum...


--------------------
Zainteresowania: C#, PHP, JS, SQL, AJAX, XML, C dla AVR
Chętnie pomogę, lecz zanim napiszesz: Wujek Google , Manual PHP
Go to the top of the page
+Quote Post
Spawnm
post
Post #3





Grupa: Moderatorzy
Postów: 4 069
Pomógł: 497
Dołączył: 11.05.2007
Skąd: Warszawa




Było, poszukaj.
Zamykam.
Go to the top of the page
+Quote Post

Closed TopicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 21.08.2025 - 00:04