How does PHP automatically jump to a specified page when an error occurs in the SQL statement?

Source: Internet
Author: User
The current use is Die ("SQL statement error");

But do not want to let users see something, what should be done?


Reply to discussion (solution)

Header ("Location: Destination"); exit ();

Header ("Location: Destination"); exit ();


Jump statements I know, but how do I get to this sentence?

For example, the current statement is mysql_query ($sql) or Die ("SQL Error");

I think you will not ask this question if you have studied object-oriented.

All SQL is executed in so many method classes, Try,catch catch errors. Jump processing

$result = mysql_query ($sql), if (! $result) {   header ("Location: Destination");   Exit ();}

The main is the error when you do not want to let users see

Then automatically jump to a specified page and output on this page, there is no difference
As with the error message, the user is now in front of

The main is the error when you do not want to let users see

Then automatically jump to a specified page and output on this page, there is no difference
As with the error message, the user is now in front of



You understand that very correctly.

I understand the right thing, and that's you. The demand description is wrong.

I understand the right thing, and that's you. The demand description is wrong.


What's your solution?

Logging errors to the log
Continue to execute the program, but need to determine the validity of the data

But as you can see in the case of your example, it's not necessary to do that.
SQL instruction errors occur only during the debugging phase, and SQL syntax errors do not occur at the formal runtime
Unless you allow users to submit SQL instructions, you should also tell the submitter that the SQL instructions are wrong

Thanks to two moderators for their responses, each of them received

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.