2
mysql_query("SELECT active...  WHERE account = '".$account."'")

x = 1;
where(x<10){
    if($active == 1){
        mysql_query("UPDATE scriptstatus SET active = '0' WHERE account = '".$account."'");

        /// Script with errors

        x++;
    }
}
mysql_query("UPDATE scriptstatus SET active = '1' WHERE account = '".$account."'");

I have a script, but it has errors and that makes the script to stop.

Can I force the script to run until the end?

4
  • 6
    Wouldn't error handling, or better yet, fixing the errors be a better solution? Commented Feb 6, 2013 at 21:11
  • What kind of errors? Runtime errors? Php errors? sql errors? Commented Feb 6, 2013 at 21:13
  • Dublicate entry 'xy' for key 'category'. MySQL, this is purpose Commented Feb 6, 2013 at 21:15
  • 2
    Don't use mysql extension use PDO or Mysqli. Commented Feb 6, 2013 at 21:19

2 Answers 2

3

No, this is not possible, nor is it a good idea. PHP-scripts are terminated upon error. The real solution would be to fix the errors instead.

A side tip: try looking into a proper IDE which informs you on potential problems and errors while you type.

Sign up to request clarification or add additional context in comments.

Comments

0

Use try catch: http://php.net/manual/en/language.exceptions.php

try {
    /// Script with errors
} catch (Exception $e) {}

2 Comments

the mysql extension doesn't throw exceptions.
@SerjSagan are we talking about the same thing here? Try/catch blocks are for exceptions. Errors/Warnings/Notices are totally different. Are you implying that a try/catch block can actually catch an Error/Warning/Notice? Check out the note from the link you provided: Internal PHP functions mainly use Error reporting, only modern Object oriented extensions use exceptions. However, errors can be simply translated to exceptions with ErrorException.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.