Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   PHP (https://www.askmehelpdesk.com/forumdisplay.php?f=454)
-   -   Insert Image in a PHP Script. Here is my error... (https://www.askmehelpdesk.com/showthread.php?t=630741)

  • Jan 26, 2012, 03:46 PM
    Scotty13
    Insert Image in a PHP Script. Here is my error...
    I don't usually don't have a problem. This is my script below, following my error message. I've tried everything. What I'm I missing?

    <img src="images/flightattendant.jpg" alt="Jeanne - Your flight attendant" width="378" height="851" align="right" />

    <?php
    Session_start();
    // Force script errors and warnings to show on page in case php.ini file is set to not display them
    Error_reporting(E_ALL);
    Ini_set('display_errors', '1');

    // Unset all of the session variables
    $_SESSION = array();
    // If it's desired to kill the session, also delete the session cookie
    If (isset($_COOKIE['idCookie'])) {
    setcookie("idCookie", '', time()-42000, '/');
    setcookie("locaCookie", '', time()-42000, '/');
    }
    // Destroy the session variables
    Session_destroy();

    // Check to see if their session is in fact destroyed
    If(!session_is_registered('firstname')){
    print "Bon Voyage... Every goodbye makes the next hello closer</font>.";

    exit();

    Header("location: index.php"); // << makes the script send them to any page we set
    } else {

    Print "<h2>Sorry - You're not able to depart at this time.</h2>";

    Exit();

    }

    ?>

    ERROR:

    Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/********/public_html/root/logout.php:2) in /home/********/public_html/root/logout.php on line 3

    Bon Voyage... Every goodbye makes the next hello closer.
  • May 30, 2012, 05:29 PM
    bobobeer
    Move the image tag below the script. You cannot have any output/text or anything else before a session_start() call. This has to do with response headers and cookies. For details on why that is please review the PHP documentation on sessions PHP: Sessions - Manual

    For future reference the same goes for a call to the header() function for the same reason as above.

  • All times are GMT -7. The time now is 12:46 AM.