Connecting Tech Pros Worldwide Forums | Help | Site Map

header location in a div !

Familiar Sight
 
Join Date: Oct 2008
Posts: 143
#1: Nov 3 '08
i got some php code that sit in a div that is refreshing every 4 seconds
and checking some data from other file:

if {data is not ok } continue

if {data is ok } go to:

header:location to some url!!


my problem is that the redirecting is displaying the data in the div tag!!

what can i do so all the page will be changed to the header location?

thanx!!

Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,949
#2: Nov 3 '08

re: header location in a div !


First of all, you can't have the header() function after you've output html - you should receive a fatal error.

Secondly, I'm not understanding the question.

Post the code you have tried.
Familiar Sight
 
Join Date: Oct 2008
Posts: 143
#3: Nov 3 '08

re: header location in a div !


this is the code!! i want that the all page will be displayed ,not in the div , this code is in a div that is called by ajax!

Expand|Select|Wrap|Line Numbers
  1. $query_102="select * from bidding_main where bid_id='$bid_id'";
  2.         $result_102=mysql_query($query_102);
  3.         $row_102=mysql_fetch_array($result_102);
  4.  
  5.         $sqlno="select * from bidding_details where bid_id=$bid_id";
  6.         $queryno=mysql_query($sqlno);
  7.         $numno=mysql_num_rows($queryno);
  8.  
  9.         $max_bid=$row_102['max_bid'];
  10.         $hbid=$max_bid-$numno;
  11.  
  12.         if($numno>=$max_bid && $dt>=$var_timestamp)
  13.         {
  14.         $sql_update1="update bidding_main set bid_status='close', end_date='$date' where bid_id='$bid_id'";
  15.         mysql_query($sql_update1)or die(mysql_error());
  16.  
  17.         $sql_update123="update bidding_details set bid_status='close' where bid_id='$bid_id'";
  18.         mysql_query($sql_update123)or die(mysql_error());
  19.  
  20.         header("Location:http://www.bonker.co.il/product_detailclose.php?bid_id=$bid_id");
  21.  
  22.         exit;
  23.         }
  24.         else {
  25.         // do nada
  26.         }
nathj's Avatar
Expert
 
Join Date: May 2007
Location: North Tyneside
Posts: 857
#4: Nov 3 '08

re: header location in a div !


Any header information has the be the first output. This means that you can have server side code before it but if anything puts information to the browser it has to come after the header command.

Having read over your code I notice that you have whitespace. this is generally good practice but as far as headers are concerned it causes problems.

Check out the manual.

Quote:

Originally Posted by PHP manual

Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. It is a very common error to read code with include(), or require(), functions, or another file access function, and have spaces or empty lines that are output before header() is called. The same problem exists when using a single PHP/HTML file

So try removing the white space, you can have many lines, just no white space between them. If that doesn't help you out post back and I'll take another look.

However, if that's a code snippet and it's actually within a div as your question suggests and you need to have the page output in there then header is not the solution for you. I'm not sure but cURL may work, it's not something I've ever used myself.


Cheers
nathj
Familiar Sight
 
Join Date: Oct 2008
Posts: 143
#5: Nov 3 '08

re: header location in a div !


i forgot to say but the code is working ,the problem is that the code is executed in the div ,not in the parent link!!

my site is built like that

i got a div tag that is refreshing with ajax ,the ajax is calling other file and display it in the div ,i put this header code in it so it will do something when needed ,so when the time comes and the code need to be executed ,it is executed but instead of in the parent page ,it is executed in the div ,its working like it is in iframe!!

tthanx!
Familiar Sight
 
Join Date: Oct 2008
Posts: 143
#6: Nov 6 '08

re: header location in a div !


i fixed it!!

i made another file with meta refresh

and in my header:location i point it to the new file ,this is the only way i found to execute header from a div!!

the header:location is siting in a div!!!


i hope it will help some one else that looking for a fix!!
Reply