Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 15 of 15
  1. #1
    New Coder
    Join Date
    Nov 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Headers Already Sent -> ob_start?

    I have this code i want to include in my template:
    PHP Code:
    <?php

    include 'config.php';

    if(isset(
    $_POST['submit']))
    {

    $first addslashes(trim($_POST['firstname']));
    $surname addslashes(trim($_POST['surname']));
    $username addslashes(trim($_POST['username']));
    $email addslashes(trim($_POST['email']));
    $pass addslashes(trim($_POST['password']));
    $conf addslashes(trim($_POST['confirm']));

    $ip $_SERVER['REMOTE_ADDR'];
    $date date("d, m y");

    if ( 
    $_POST['password'] == $_POST['confirm'] )
    {}else{

    echo 
    '<script>alert("Your passwords were not the same, please enter the same password in each field.");</script>';
    echo 
    '<script>history.back(1);</script>';
    exit;

    }

    $password md5($pass);

    if ((((( empty(
    $first) ) || ( empty($surname) ) || ( empty($username) ) || ( empty($email) ) || ( empty($password) )))))
    {

    echo 
    '<script>alert("One or more fields was left empty, please try again.");</script>';
    echo 
    '<script>history.back(1);</script>';
    exit;

    }

    if((!
    strstr($email "@")) || (!strstr($email ".")))
    {

    echo 
    '<script>alert("You entered an invalid email address. Please try again.");</script>';
    echo 
    '<script>history.back(1);</script>';
    exit;

    }

    $q mysql_query("SELECT * FROM Users WHERE Username = '$username'") or die(mysql_error());
    if(
    mysql_num_rows($q) > 0)
    {

    echo 
    '<script>alert("The username you entered is already in use, please try again.");</script>';
    echo 
    '<script>history.back(1);</script>';
    exit;

    }

    $name $first ' ' $surname;
    $actkey mt_rand(1500).'f78dj899dd';
    $act sha1($actkey);

    $query mysql_query("INSERT INTO Users (Username, Password, Name, Email, Date, IP, Actkey) VALUES ('$username','$password','$name','$email','$date','$ip','$act')") or die(mysql_error());
    $send mail($email "Registration Confirmation" "Thank you for registering with YourWebsite.\n\nYour username and password is below, along with details on how to activate your account.\n\nUser: ".$username."\nPass: ".$pass."\n\nClick the link below to activate your account:\nhttp://EDITTHISURL.COM/activate.php?id=".$act."\n\nPlease do not reply, this is an automated mailer.\n\nThanks""FROM: auto@mailer.com");

    if((
    $query)&&($send))
    {

    echo 
    ' <html>
    <head>
    <title>Success</title>
    <link href="style.css" rel="stylesheet" type="text/css">
    </head>

    <body>

    <div id="success">
    <p>Thank you for registering, you will recieve an email soon with your login details and your activation link so that you can activate your account.</p>
    <p><a href="login.php">Click here</a> to login once you have activated.</p>
    </div>

    </body>
    </html>
    '
    ;

    } else {

    echo 
    '
    <html>
    <head>
    <title>Error</title>
    <link href="style.css" rel="stylesheet" type="text/css">
    </head>

    <body>

    <div id="error">
    <p>We are sorry, there appears to be a problem with our script at the moment.</p>
    <p>Your data was not lost. Username: '
    .$username.' | Password: '.$pass.' | Email: '.$email.' | Full name: '.$name.'</p>
    <p>Please try again later.</p>
    </div>

    </body>
    </html>
    '
    ;

    }

    } else {

    ?>
    <html>
    <head>
    <title>Register</title>
    <link href="style.css" rel="stylesheet" type="text/css">
    </head>

    <body>

    <div id="wrapper">

    <div id="head">the registration page</div>
    <br>
    <div id="main">
    <p>Welcome to the registration, fill out the form below and hit Submit. All fields are required,so fill them all out! </p>
    <form action="<?= $_SERVER['PHP_SELF'?>" method="post">
    <table width="100%" border="0" cellpadding="0" cellspacing="0">
    <tr>
    <td width="50%">First name </td>
    <td width="50%"><input name="firstname" type="text" id="firstname"></td>
    </tr>
    <tr>
    <td>Surname</td>
    <td><input name="surname" type="text" id="surname"></td>
    </tr>
    <tr>
    <td>Email Address </td>
    <td><input name="email" type="text" id="email"></td>
    </tr>
    <tr>
    <td>Username</td>
    <td><input name="username" type="text" id="username"></td>
    </tr>
    <tr>
    <td>Password</td>
    <td><input name="password" type="password" id="password"></td>
    </tr>
    <tr>
    <td>Confirm Password </td>
    <td><input name="confirm" type="password" id="confirm"></td>
    </tr>
    <tr>
    <td>Register</td>
    <td><input name="submit" type="submit" class="textBox" value="Submit"></td>
    </tr>
    </table>
    </form>
    Upon confirmation of your details, you will be sent an email containing your username, password and details on how to activate your account so as to be able to use this website. </div>

    </div>

    </body>
    </html>

    <? mysql_close($l); ?>
    How can I do this without getting a "Headers already sent" error?
    (And no, I can't put everything on top of the page, before the <html> tag)

    Thanks for your replies :)

    dEUS
    Last edited by dEUS; 11-26-2006 at 07:53 PM.
    PHP Code:
    <?php echo 'lol?' ?>

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    New Coder
    Join Date
    Nov 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    1. Plan your scripts so that you get all the header-related stuff out of the way before you start outputting any content. In some cases (such as when you're redirecting the client by sending a Location: header) you don't need to send any content at all, and by doing so you're just slowing your site down.
    2. Use ob_start() and ob_end_flush(). These functions have their uses. ob_start() turns on an "output buffer" and any content that would have been sent to the client is instead stored in this buffer, until ob_end_flush() (or the end of the script) is called, where it will output everything that has been buffered. There are three main problems with this. First, by delaying sending output you're slowing your page's response; Apache at least can be sending content to the client and the user will be getting stuff on the screen even while the script is still running (and that offers opportunities for clever little programming tricks in itself). Second, PHP has to hold on to the contents of that buffer, instead of just outputting it and forgetting it (the output buffer is intended to allow PHP to reprocess pages it has already generated); memory has to be allocated to store buffered page; in a heavily-loaded environment this can get quite messy, bogging the memory routines down. Third, it's just plain clumsy.
    3. Switch on output buffering in php.ini. Not entirely sure why this option would be a good idea; it's option 2 applied to every page whether it's needed there or not (I understand this is how ASP works). Not only that, but it assumes that the hosting server has the same ini setting.
    Ok, so this is not a good idea. How do i arrange the code then? (i did not write that piece of code myself, i'm a PHP noob )
    Which parts must go to the top of the page? And how do i keep the if / else statements working?

    Thank you for trying to help me
    Last edited by dEUS; 11-26-2006 at 08:37 PM.
    PHP Code:
    <?php echo 'lol?' ?>

  • #4
    New Coder
    Join Date
    Nov 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    **Bump** Sorry
    Last edited by dEUS; 11-27-2006 at 08:23 PM.
    PHP Code:
    <?php echo 'lol?' ?>

  • #5
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,824
    Thanks
    19
    Thanked 157 Times in 148 Posts
    ob_start and ob_end_flush are not that evil unless you really notice a drop off in speed...sometimes they are necessary

    ON what line are you receiving your error message, and what is the error message?
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :-)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!
    ♪♪ …Need Web Hosting For My YouTube-To-Mp3 Conversion Software? Check Here !!… ♪♪

  • #6
    New Coder
    Join Date
    Nov 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'm having a little problem with my WAMPserver, i'll post the error tomorrow, if i'm not going to have it fixed sooner...
    PHP Code:
    <?php echo 'lol?' ?>

  • #7
    New Coder
    Join Date
    Nov 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question

    Ok, so this is the error i get:
    Code:
    Parse error:  parse error, unexpected $end in C:\Wamp\www\register.php on line 342
    This is the full PHP code of the page (the previous code was of the script only)

    PHP Code:
    <?php

    include 'config.php';

    if(isset(
    $_POST['submit']))
    {

    $first addslashes(trim($_POST['firstname']));
    $surname addslashes(trim($_POST['surname']));
    $username addslashes(trim($_POST['username']));
    $email addslashes(trim($_POST['email']));
    $pass addslashes(trim($_POST['password']));
    $conf addslashes(trim($_POST['confirm']));

    $ip $_SERVER['REMOTE_ADDR'];
    $date date("d, m y");

    if ( 
    $_POST['password'] == $_POST['confirm'] )
    {}else{

    echo 
    '<script>alert("Your passwords were not the same, please enter the same password in each field.");</script>';
    echo 
    '<script>history.back(1);</script>';
    exit;

    }

    $password md5($pass);

    if ((((( empty(
    $first) ) || ( empty($surname) ) || ( empty($username) ) || ( empty($email) ) || ( empty($password) )))))
    {

    echo 
    '<script>alert("One or more fields was left empty, please try again.");</script>';
    echo 
    '<script>history.back(1);</script>';
    exit;

    }

    if((!
    strstr($email "@")) || (!strstr($email ".")))
    {

    echo 
    '<script>alert("You entered an invalid email address. Please try again.");</script>';
    echo 
    '<script>history.back(1);</script>';
    exit;

    }

    $q mysql_query("SELECT * FROM Users WHERE Username = '$username'") or die(mysql_error());
    if(
    mysql_num_rows($q) > 0)
    {

    echo 
    '<script>alert("The username you entered is already in use, please try again.");</script>';
    echo 
    '<script>history.back(1);</script>';
    exit;

    }

    $name $first ' ' $surname;
    $actkey mt_rand(1500).'f78dj899dd';
    $act sha1($actkey);

    $query mysql_query("INSERT INTO Users (Username, Password, Name, Email, Date, IP, Actkey) VALUES ('$username','$password','$name','$email','$date','$ip','$act')") or die(mysql_error());
    $send mail($email "Registration Confirmation" "Thank you for registering with YourWebsite.\n\nYour username and password is below, along with details on how to activate your account.\n\nUser: ".$username."\nPass: ".$pass."\n\nClick the link below to activate your account:\nhttp://EDITTHISURL.COM/activate.php?id=".$act."\n\nPlease do not reply, this is an automated mailer.\n\nThanks""FROM: auto@mailer.com");

    if((
    $query)&&($send))
    {

    echo 
    ' <html>
    <head>
    <title>Success</title>
    <link href="style.css" rel="stylesheet" type="text/css">
    </head>

    <body>

    <div id="success">
    <p>Thank you for registering, you will recieve an email soon with your login details and your activation link so that you can activate your account.</p>
    <p><a href="login.php">Click here</a> to login once you have activated.</p>
    </div>

    </body>
    </html>
    '
    ;

    } else {

    echo 
    '
    <html>
    <head>
    <title>Error</title>
    <link href="style.css" rel="stylesheet" type="text/css">
    </head>

    <body>

    <div id="error">
    <p>We are sorry, there appears to be a problem with our script at the moment.</p>
    <p>Your data was not lost. Username: '
    .$username.' | Password: '.$pass.' | Email: '.$email.' | Full name: '.$name.'</p>
    <p>Please try again later.</p>
    </div>

    </body>
    </html>
    '
    ;

    }

    } else {

    ?>
    <?php
    $starttime 
    microtime();
    $startarray explode(" "$starttime);
    $starttime $startarray[1] + $startarray[0];
    ?>
    <html>
    <head>
    <meta http-equiv="Content-Language" content="nl-be">
    <title>2nd Level Gaming // Taking gaming to the next level</title>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <link href="/stijl.css" rel="stylesheet" type="text/css"></head>
    <body bgcolor="#293238" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" text="#FFFFFF">
    <center>
      <table id="Table_01" width="901" height="1000" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td colspan="37"><img src="images/index_01.gif" width="900" height="66" alt=""></td>
          <td><img src="images/spacer.gif" width="1" height="66" alt=""></td>
        </tr>
        <tr>
          <td colspan="6" rowspan="5"><img src="images/index_02.gif" width="97" height="220" alt=""></td>
          <td colspan="25"><img src="images/index_03.gif" width="708" height="170" alt=""></td>
          <td colspan="6" rowspan="4"><img src="images/index_04.gif" width="95" height="217" alt=""></td>
          <td><img src="images/spacer.gif" width="1" height="170" alt=""></td>
        </tr>
        <tr>
          <td colspan="25"><img src="images/index_05.gif" width="708" height="20" alt=""></td>
          <td><img src="images/spacer.gif" width="1" height="20" alt=""></td>
        </tr>
        <tr>
          <td rowspan="3"><img src="images/index_06.gif" width="53" height="30" alt=""></td>
          <td><a href="index.html"> <img src="images/home.gif" width="50" height="16" alt="" border="0"></a></td>
          <td rowspan="3"><img src="images/index_08.gif" width="17" height="30" alt=""></td>
          <td><a href="backup.html"> <img src="images/reviews.gif" width="65" height="16" alt="" border="0"></a></td>
          <td rowspan="3"><img src="images/index_10.gif" width="15" height="30" alt=""></td>
          <td colspan="5"><img src="images/previews.gif" width="74" height="16" alt=""></td>
          <td rowspan="3"><img src="images/index_12.gif" width="14" height="30" alt=""></td>
          <td><img src="images/games.gif" width="56" height="16" alt=""></td>
          <td rowspan="3"><img src="images/index_14.gif" width="14" height="30" alt=""></td>
          <td><img src="images/specials.gif" width="72" height="16" alt=""></td>
          <td rowspan="3"><img src="images/index_16.gif" width="20" height="30" alt=""></td>
          <td colspan="7"><img src="images/community.gif" width="84" height="16" alt=""></td>
          <td rowspan="2"><img src="images/index_18.gif" width="14" height="27" alt=""></td>
          <td><img src="images/user_menu.gif" width="80" height="16" alt=""></td>
          <td rowspan="2"><img src="images/index_20.gif" width="80" height="27" alt=""></td>
          <td><img src="images/spacer.gif" width="1" height="16" alt=""></td>
        </tr>
        <tr>
          <td rowspan="2"><img src="images/index_21.gif" width="50" height="14" alt=""></td>
          <td rowspan="2"><img src="images/index_22.gif" width="65" height="14" alt=""></td>
          <td colspan="5" rowspan="2"><img src="images/index_23.gif" width="74" height="14" alt=""></td>
          <td rowspan="2"><img src="images/index_24.gif" width="56" height="14" alt=""></td>
          <td rowspan="2"><img src="images/index_25.gif" width="72" height="14" alt=""></td>
          <td colspan="7"><img src="images/index_26.gif" width="84" height="11" alt=""></td>
          <td><img src="images/index_27.gif" width="80" height="11" alt=""></td>
          <td><img src="images/spacer.gif" width="1" height="11" alt=""></td>
        </tr>
        <tr>
          <td colspan="5"><img src="images/index_28.gif" width="44" height="3" alt=""></td>
          <td colspan="10" rowspan="2"><img src="images/index_29.gif" width="258" height="25" alt=""></td>
          <td rowspan="4"><img src="images/index_30.gif" width="51" height="159" alt=""></td>
          <td><img src="images/spacer.gif" width="1" height="3" alt=""></td>
        </tr>
        <tr>
          <td colspan="2"><img src="images/index_31.gif" width="51" height="22" alt=""></td>
          <td colspan="11"><img src="images/index_32.gif" width="261" height="22" alt=""></td>
          <td rowspan="3"><img src="images/index_33.gif" width="4" height="156" alt=""></td>
          <td colspan="11"><img src="images/index_34.gif" width="268" height="22" alt=""></td>
          <td rowspan="3"><img src="images/index_35.gif" width="7" height="156" alt=""></td>
          <td><img src="images/spacer.gif" width="1" height="22" alt=""></td>
        </tr>
        <tr>
          <td rowspan="2"><img src="images/index_36.gif" width="49" height="134" alt=""></td>
          <td colspan="2"><img src="images/index_37.gif" width="5" height="125" alt=""></td>
          <td colspan="9" background="images/content_links.gif">&nbsp;</td>
          <td><img src="images/index_39.gif" width="3" height="125" alt=""></td>
          <td><img src="images/index_40.gif" width="3" height="125" alt=""></td>
          <td colspan="9" background="images/content_midden.gif">&nbsp;</td>
          <td><img src="images/index_42.gif" width="2" height="125" alt=""></td>
          <td><img src="images/index_43.gif" width="2" height="125" alt=""></td>
          <td colspan="8" background="images/content_rechts.gif">&nbsp;</td>
          <td><img src="images/index_45.gif" width="1" height="125" alt=""></td>
          <td><img src="images/spacer.gif" width="1" height="125" alt=""></td>
        </tr>
        <tr>
          <td><img src="images/index_46.gif" width="2" height="9" alt=""></td>
          <td colspan="11"><img src="images/index_47.gif" width="261" height="9" alt=""></td>
          <td colspan="11"><img src="images/index_48.gif" width="268" height="9" alt=""></td>
          <td colspan="10"><img src="images/index_49.gif" width="258" height="9" alt=""></td>
          <td><img src="images/spacer.gif" width="1" height="9" alt=""></td>
        </tr>
        <tr>
          <td colspan="37" background="images/index_50.gif">&nbsp;</td>
          <td><img src="images/spacer.gif" width="1" height="20" alt=""></td>
        </tr>
        <tr>
          <td colspan="22"><img src="images/index_51.gif" width="557" height="2" alt=""></td>
          <td colspan="11" rowspan="2"><img src="images/index_52.gif" width="276" height="4" alt=""></td>
          <td colspan="4" rowspan="5" background="images/index_53.gif">&nbsp;</td>
          <td><img src="images/spacer.gif" width="1" height="2" alt=""></td>
        </tr>
        <tr>
          <td colspan="5" rowspan="4" background="images/index_54.gif">&nbsp;</td>
          <td colspan="17" rowspan="2" background="images/index_55.gif"><p style="margin-left: 4px"><strong><font size="2" face="Verdana">Registratie @ PureGaming </font></strong></td>
          <td><img src="images/spacer.gif" width="1" height="2" alt=""></td>
        </tr>
        <tr>
          <td rowspan="2"><img src="images/index_56.gif" width="2" height="99" alt=""></td>
          <td colspan="9" rowspan="2" background="images/index_57.gif"><table border="0" cellpadding="0" cellspacing="0" width="100%" id="table6">
              <tr></tr>
          </table></td>
          <td rowspan="2"><img src="images/index_58.gif" width="3" height="99" alt=""></td>
          <td><img src="images/spacer.gif" width="1" height="27" alt=""></td>
        </tr>
        <tr>
          <td colspan="17" rowspan="2"><img src="images/registratie_news_banner.gif" width="487" height="85" alt=""></td>
          <td><img src="images/spacer.gif" width="1" height="72" alt=""></td>
        </tr>
        <tr>
          <td colspan="11"><img src="images/index_60.gif" width="276" height="13" alt=""></td>
          <td><img src="images/spacer.gif" width="1" height="13" alt=""></td>
        </tr>
        <tr>
          <td colspan="4" background="images/index_61.gif" height="100%">&nbsp;</td>
          <td colspan="30" background="images/index_62.gif" height="100%">
          <div id="body">
            <p align="center"><div id="main">
    <p>Welcome to the registration, fill out the form below and hit Submit. All fields are required,so fill them all out! </p>
    <form action="<?= $_SERVER['PHP_SELF'?>" method="post">
    <table width="100%" border="0" cellpadding="0" cellspacing="0">
    <tr>
    <td width="50%" id="body"><strong>First name </strong></td>
    <td width="50%"><input name="firstname" type="text" id="firstname"></td>
    </tr>
    <tr>
    <td id="body"><strong>Surname</strong></td>
    <td><input name="surname" type="text" id="surname"></td>
    </tr>
    <tr>
    <td id="body"><strong>Email Address </strong></td>
    <td><input name="email" type="text" id="email"></td>
    </tr>
    <tr>
    <td id="body"><strong>Username</strong></td>
    <td><input name="username" type="text" id="username"></td>
    </tr>
    <tr>
    <td id="body"><strong>Password</strong></td>
    <td><input name="password" type="password" id="password"></td>
    </tr>
    <tr>
    <td id="body"><strong>Confirm Password </strong></td>
    <td><input name="confirm" type="password" id="confirm"></td>
    </tr>
    <tr>
    <td id="body"><strong>Register</strong></td>
    <td><input name="submit" type="submit" class="textBox" value="Submit"></td>
    </tr>
    </table>
    </form>
    Upon confirmation of your details, you will be sent an email containing your username, password and details on how to activate your account so as to be able to use this website. </div>

            <p align="center">&nbsp;</p>
            <p align="center">&nbsp;</p>
            <p align="center">&nbsp;</p>
            <p align="center">&nbsp;</p>
            <p align="center">&nbsp;</p>
            <p align="center">&nbsp;</p>
            <p align="center">&nbsp;</p>
            <p align="center">&nbsp;</p>
            <p align="center">&nbsp;</p>
            <p align="center">&nbsp;</p>
            <p align="center"><font size="1">
              <?php
    $endtime 
    microtime();
    $endarray explode(" "$endtime);
    $endtime $endarray[1] + $endarray[0];
    $totaltime $endtime $starttime;
    echo 
    "Pagina gegenereerd in $totaltime seconden.";
    ?></font>
              </p>
          </div>
          </td>
          <td colspan="3" background="images/index_63.gif" height="100%">&nbsp;</td>
          <td><img src="images/spacer.gif" width="1" height="100" alt=""></td>
        </tr>
        <tr>
          <td colspan="37"><img src="images/index_64.gif" width="900" height="68" alt=""></td>
          <td><img src="images/spacer.gif" width="1" height="68" alt=""></td>
        </tr>
        <tr>
          <td><img src="images/spacer.gif" width="49" height="1" alt=""></td>
          <td><img src="images/spacer.gif" width="2" height="1" alt=""></td>
          <td><img src="images/spacer.gif" width="3" height="1" alt=""></td>
          <td><img src="images/spacer.gif" width="2" height="1" alt=""></td>
          <td><img src="images/spacer.gif" width="14" height="1" alt=""></td>
          <td><img src="images/spacer.gif" width="27" height="1" alt=""></td>
          <td><img src="images/spacer.gif" width="53" height="1" alt=""></td>
          <td><img src="images/spacer.gif" width="50" height="1" alt=""></td>
          <td><img src="images/spacer.gif" width="17" height="1" alt=""></td>
          <td><img src="images/spacer.gif" width="65" height="1" alt=""></td>
          <td><img src="images/spacer.gif" width="15" height="1" alt=""></td>
          <td><img src="images/spacer.gif" width="12" height="1" alt=""></td>
          <td><img src="images/spacer.gif" width="3" height="1" alt=""></td>
          <td><img src="images/spacer.gif" width="4" height="1" alt=""></td>
          <td><img src="images/spacer.gif" width="3" height="1" alt=""></td>
          <td><img src="images/spacer.gif" width="52" height="1" alt=""></td>
          <td><img src="images/spacer.gif" width="14" height="1" alt=""></td>
          <td><img src="images/spacer.gif" width="56" height="1" alt=""></td>
          <td><img src="images/spacer.gif" width="14" height="1" alt=""></td>
          <td><img src="images/spacer.gif" width="72" height="1" alt=""></td>
          <td><img src="images/spacer.gif" width="20" height="1" alt=""></td>
          <td><img src="images/spacer.gif" width="10" height="1" alt=""></td>
          <td><img src="images/spacer.gif" width="2" height="1" alt=""></td>
          <td><img src="images/spacer.gif" width="23" height="1" alt=""></td>
          <td><img src="images/spacer.gif" width="2" height="1" alt=""></td>
          <td><img src="images/spacer.gif" width="7" height="1" alt=""></td>
          <td><img src="images/spacer.gif" width="2" height="1" alt=""></td>
          <td><img src="images/spacer.gif" width="38" height="1" alt=""></td>
          <td><img src="images/spacer.gif" width="14" height="1" alt=""></td>
          <td><img src="images/spacer.gif" width="80" height="1" alt=""></td>
          <td><img src="images/spacer.gif" width="80" height="1" alt=""></td>
          <td><img src="images/spacer.gif" width="25" height="1" alt=""></td>
          <td><img src="images/spacer.gif" width="3" height="1" alt=""></td>
          <td><img src="images/spacer.gif" width="11" height="1" alt=""></td>
          <td><img src="images/spacer.gif" width="4" height="1" alt=""></td>
          <td><img src="images/spacer.gif" width="1" height="1" alt=""></td>
          <td><img src="images/spacer.gif" width="51" height="1" alt=""></td>
          <td></td>
        </tr>
      </table>
    </center>
    </body>
    </html>
    Line 342:
    PHP Code:
    </html
    Now, my question was, how can i implement the ob_start here? (How do i do this, where do i put <?php ob_start; ?> etc...)

    Thanks!
    Last edited by dEUS; 11-27-2006 at 09:46 PM.
    PHP Code:
    <?php echo 'lol?' ?>

  • #8
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,824
    Thanks
    19
    Thanked 157 Times in 148 Posts
    That's not a header error/warning -- that;s a parse error. There is something wrong with your syntax.

    Check your if/else statements. It looks like your missing a closing bracket (}) somewhere. Possibly at the very end, so your code would look like:

    PHP Code:
          <td><img src="images/spacer.gif" width="11" height="1" alt=""></td>
          <td><img src="images/spacer.gif" width="4" height="1" alt=""></td>
          <td><img src="images/spacer.gif" width="1" height="1" alt=""></td>
          <td><img src="images/spacer.gif" width="51" height="1" alt=""></td>
          <td></td>
        </tr>
      </table>
    </center>
    </body>
    </html>

    <? ?>
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :-)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!
    ♪♪ …Need Web Hosting For My YouTube-To-Mp3 Conversion Software? Check Here !!… ♪♪

  • #9
    New Coder
    Join Date
    Nov 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Nope, this gives me the same error message.
    If i have to break up the code, how would i do this? (the echos must be called in a specified div layer.)
    PHP Code:
    <?php echo 'lol?' ?>

  • #10
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,824
    Thanks
    19
    Thanked 157 Times in 148 Posts
    if and when you decide that you need to use ob_start and ob_end_flush, it would look something like this:

    PHP Code:
    <?

    ob_start
    ();

    echo 
    '<p>....</p>';  // Some HTML here. Doesn;t have to be HTML though -- Anything that sends output to the browser will trigger a "Headers already sent" warning/error.

    // Main PHP/HTML code here, that does whatever

    ob_end_flush();

    ?>
    I should reiterate that if you can find a way to reorganize your PHP/HTML so that these functions aren;t necessary, then you should. It's generally a better coding practice (and will eliminate the buffer overhead these functions sometimes cause).

    Edit: And ob_start/ob_end_flush won;t fix your parse error!
    Last edited by chump2877; 11-28-2006 at 10:26 PM.
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :-)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!
    ♪♪ …Need Web Hosting For My YouTube-To-Mp3 Conversion Software? Check Here !!… ♪♪

  • #11
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,107
    Thanks
    2
    Thanked 326 Times in 318 Posts
    I don't see anything in the posted code that makes use of a header.

    In your first post you state you include this in a template. Aside from the parse error this code is experiencing, I would guess that your template file is doing a session_start or setting a cookie after this code.

    Once you correct the current error, post the actual header related error message that caused your initial problem.
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #12
    New Coder
    Join Date
    Nov 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well, I don't know why I got the idea I had an "headers already sent" error, that's from another tutorial I think... I'm messing things up, i'm sorry..

    So, i would like to tidy up the code. How would it do this?

    Quote Originally Posted by chump2877
    I should reiterate that if you can find a way to reorganize your PHP/HTML so that these functions aren;t necessary
    Thanks
    PHP Code:
    <?php echo 'lol?' ?>

  • #13
    New Coder
    Join Date
    Nov 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Bump?
    PHP Code:
    <?php echo 'lol?' ?>

  • #14
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,824
    Thanks
    19
    Thanked 157 Times in 148 Posts
    So, i would like to tidy up the code. How would it do this?
    That;s a very general question, can you expand on that? Have you fixed your parse error yet?
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :-)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!
    ♪♪ …Need Web Hosting For My YouTube-To-Mp3 Conversion Software? Check Here !!… ♪♪

  • #15
    New Coder
    Join Date
    Nov 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I found a way to fix this, nevermind guys!
    I just include my template in every echo (this could generate large files though )
    Last edited by dEUS; 11-30-2006 at 07:35 PM.
    PHP Code:
    <?php echo 'lol?' ?>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •