SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Feb 2003
    Location
    Berlin
    Posts
    370
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Function exit() - a way not to terminate the script?

    Is there a way not to terminate the whole script when using exit() or is there a other function to do so?

    I have a page with mixed with html an php:

    PHP Code:
    <body>
    html1
    <?php 1?>

    html2
    <?php 2?>

    html3
    <?php 3?>
    </body>
    The first php looks if a file exists and if true, it unlinks it. The second php deletes a dataset from a sql database. The third is only an include for the page footer.

    Now if deleting the file fails, i also don't want anything deleted from the database. Thus it used an exit() in the first php if it fails to stop the function of the second php.
    But still I want the footer of the page...

    Flözen

  2. #2
    Sidewalking anode's Avatar
    Join Date
    Mar 2001
    Location
    Philadelphia, US
    Posts
    2,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You'll have to branch somewhere. Either use a flag to indicate that the file deletion failed and check for it before you do your database deletion, or put the rest of your page(after the file deletion bit) in a function and give that function as the argument to exit.
    TuitionFree — a free library for the self-taught
    Anode Says...Blogging For Your Pleasure


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
  •