1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

program error

Discussion in 'PHP' started by kharearch, Dec 29, 2007.

  1. #1
    It is showing following error on execution of my program-

    Warning: Cannot modify header information - headers already sent by (output started at /home/sanganak/public_html/dwarka_parichay_copy/add.php:10) in /home/sanganak/public_html/dwarka_parichay_copy/add.php on line 24

    My code is -

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body>
    <?php
    $con = mysql_connect("localhost","sanganak_manish","manish");

    if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }mysql_select_db("sanganak_mydata",$con);
    $s = $_POST['name'];
    //$p="mohan";
    echo $s;
    echo $p;
    ob_start();
    if($s == "mohan")
    {
    header('Location:http://sanganak.co.in/dwarka_parichay_copy/useful_links.htm');
    }
    mysql_close($con);
    ?>
    </body>
    </html>
     
    kharearch, Dec 29, 2007 IP
  2. dataman

    dataman Peon

    Messages:
    94
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You can't output any content if your sending a header(); unless you use the ob_... function(s) list before any output. But the better way is to rearrange your code, so it uses the logic that it really needed to begin with. So move the "ob_start();" up to the beginning of your script, right before "<!DOCTYPE...", add...

    <?php
    ob_start ();
    ?>
    PHP:
     
    dataman, Dec 29, 2007 IP