SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Nov 2004
    Location
    South Africa
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question What's wrong here / Stripping subdir's

    Greetz all,

    I've run across 2 problems this n00b just can't solve...

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

    PROBLEM #1

    I have one of those nifty PHP GD security image scripts running on my site (tutorial @ phpnoise.com :] )

    It gives me this error though: A non-fatal error occurred at line 3 of file /home/justride/public_html/jr/pages/verify.inc.php.<br />The error message was "session_start(): Cannot send session cookie - headers already sent by (output started at /home/justride/public_html/jr/index.php:23)"


    If I remove the PHP from my verify.inc.php page, it shows no errors, even though the code shows no signs of Header statements, or cookie statments..

    Here is the code:...

    A non-fatal error occurred at line 3 of file /home/justride/public_html/jr/pages/verify.inc.php.<br />The error message was "session_start(): Cannot send session cookie - headers already sent by (output started at /home/justride/public_html/jr/index.php:23)"

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

    PROBLEM #2

    I'm using $_SERVER['SCRIPT_FILENAME'] to get the file name of my current page, which is in a subdirectory ( /dir/page.php )

    How can I strip the subdir? I just want 'page.php'

    EG: <?php $last_modified = filemtime($_SERVER['SCRIPT_FILENAME']); print "Last modified " . date("l, dS F, Y @ h:ia", $last_modified); ?>

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

    Any help appreciated.

    Thanks, Nicholas

  2. #2
    SitePoint Member
    Join Date
    Jan 2005
    Location
    Indianapolis
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    For the first, it doesn't necesssarily have to be PHP code that is causing your error. If you output anything to the browser before a session_start() call (that includes whitespace, <html> tags, etc.) then it will throw that error. So I'd review all your code and make sure that nothing is getting sent before that session_start() call.

    For the second, if you're only ever going to be one dir deep, the easiest way is to explode the SCRIPT_FILENAME by '/' and print the second array index.
    Dave Scott
    President/CEO
    The Sonic Group, LLC


Bookmarks

Posting Permissions

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