Wrox Programmer Forums
|
Pro PHP Advanced PHP coding discussions. Beginning-level questions will be redirected to the Beginning PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 25th, 2006, 04:50 AM
Authorized User
 
Join Date: Jan 2006
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default "PHP Header"

Hi,

    I am wasting most of my time on this line.
    header("Location: myorder.php");
    exit();
This line is giving error (Cannot modify header information - headers already sent by (output started at c:\inetpub\wwwroot\arby_motorsByAsif\add-to-order.php:8) in c:\inetpub\wwwroot\arby_motorsByAsif\add-to-order.php on line 58
).

I am already handling the session on this page and using the line of COde:
ob_start();
require_once(Connectoins/Session.php);
on the top of this page.

pLZ give me some tips to overcome this diffulty and this page b redirected on the "myorder.php:)".
 
Old January 25th, 2006, 06:14 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

Hii heerajee!!

Please check any blank space\tab before the <? ?>tag

Hope this will help you



Cheers :)

vinod
 
Old January 25th, 2006, 09:12 AM
Authorized User
 
Join Date: Jan 2006
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

     Thansk Vinod, i am successfull and now i am not facing the problems bz i have removed the every thing over and beneath this tag<? ?>.

But one thing is there, if we are using header(); inside a form and that will definitely have some body and title tags and then this php tag <? ?> will be between them, then how will v use this header function.

Example::::::::::::::::::::::::::::::::::::::::::: ::::::::::::Example
<?php
ob_start();
require_once("Connections/Session.php");
require("Connections/Cn.php");
require("header.php");
print "Weocome we are on the add-to-order.php page";
if(isset($HTTP_GET_VARS['e_']))
 {
  $stock_id=d_crypt($HTTP_GET_VARS['e_']);
  mysql_select_db($database_Cn, $Cn);
  $selectQry="select * from cart where cart_stock_id='".$stock_id."' and cart_session='".$sid."'";
  $selectRes=mysql_query($selectQry) or print mysql_error();
  if(mysql_num_rows($selectRes)<1)
   {
    $insertQry="insert into cart(cart_session, cart_stock_id, cart_date)
                 values('".$sid."','".$stock_id."',now())";
    $insertRes=mysql_query($insertQry) or print mysql_error();
   }
  $today_minus_2=time()-172800;
  $today_minus_2=date("y-m-d", $today_minus_2);
  $deleteQry="delete from cart where cart_order_id='0' and cart_date<='".$today_minus_2."'";
  $deleteRes=mysql_query($deleteQry) or print mysql_error();
 }
header("Location: myorder.php");
exit(1);
?>

but what if this all the code comes inside the..............
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=shift_jis">
<title>Untitled Document</title>
</head>
<body>
<?php
............
..........
?>
</body>
</html> (Then it gives the error), so what is the solution.
Alot of Thanks.

 
Old January 25th, 2006, 10:47 AM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

HTTP headers cannot be send after output has begun.
http://www.php.net/header

If you need to do this from within a document, you'll need to engage an output buffer.
http://us3.php.net/manual/en/ref.outcontrol.php

HTH!

Regards,
Rich

--
[http://www.smilingsouls.net]
Mail_IMAP: A PHP/C-Client/PEAR solution for webmail
Author: Beginning CSS: Cascading Style Sheets For Web Design





Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling Header Using PHP! Ganich PHP How-To 0 April 9th, 2007 11:04 AM
header("location:./in.php"); [email protected] PHP How-To 0 November 25th, 2006 08:27 AM
chp2 can't see header.php in directory sgibsonart BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 0 February 3rd, 2005 10:34 AM
can't see header.php in directory sgibsonart Beginning PHP 1 February 3rd, 2005 10:32 AM
PHP ( Cannot modify header information) squared_ring Beginning PHP 6 August 14th, 2004 05:29 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.