Jump to content


PHP Navigation Problems


6 replies to this topic

#1 JoeVincetti

    Young Padawan

  • Members
  • Pip
  • 82 posts

Posted 29 May 2005 - 09:54 PM

I'm having problems when I tried using a navigation script. The script works fine, except for one thing. When I put index.php?page=news, im given the news page. The problem is that when I try setting a cookie im given :
Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/index.php:8) in /var/www/html/myplace/login.php on line 93
Is there a way i could fix this without using iframes?

#2 fiv3isaliv3

    Young Padawan

  • Members
  • Pip
  • 258 posts
  • Gender:Male

Posted 29 May 2005 - 10:12 PM

where is the form posting to?

#3 JoeVincetti

    Young Padawan

  • Members
  • Pip
  • 82 posts

Posted 29 May 2005 - 11:19 PM

I fixed the original problem, though a new problem has arose [Above^^]. Thanks for the quick response.

#4 fiv3isaliv3

    Young Padawan

  • Members
  • Pip
  • 258 posts
  • Gender:Male

Posted 29 May 2005 - 11:59 PM

... how about not sending the header information twice?

#5 adam123

    Retired P2L Staff

  • Members
  • PipPipPipPip
  • 2,306 posts
  • Location:London, UK
  • Interests:Programming and stuff.

Posted 30 May 2005 - 02:26 AM

In PHP, you must set cookies, change the header type, etc. before anything is sent to the browser. There are two ways to get around this.

One, move the setcookie function in your script so it above everything (<html>, doctype, etc.) so that it will be set before the page is loaded and the header error won't appear.

Two, if you must have the cookie where it is, you can use a little work around.
Above everything (<html>, doctype, everything), put:
<?php
ob_start()
?>

Then right at the end of your page put:
<?php
ob_end_flush()
?>


#6 JoeVincetti

    Young Padawan

  • Members
  • Pip
  • 82 posts

Posted 30 May 2005 - 09:15 AM

Thanks A lot, I followed your advice and my page is working. Thanks again for the quick response.

#7 adam123

    Retired P2L Staff

  • Members
  • PipPipPipPip
  • 2,306 posts
  • Location:London, UK
  • Interests:Programming and stuff.

Posted 30 May 2005 - 09:17 AM

No problem :)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users