Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8928743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:31:02+00:00 2026-06-15T08:31:02+00:00

I have a web application I wrote in PHP. I use a single Class

  • 0

I have a web application I wrote in PHP. I use a single Class to handle almost everything this app does. I predefine a few things before the class such as database name. What I was hoping for is that I could set a define for mysql_error().

So when I run a SQL query and add die() of error, I want it to ouput “An Error Has Occurred!” if the app is running in a production environment, but then I can change the 1 define from define(“DIEOUTPUT”, “An Error Has Occurred!”) to define(“DIEOUTPUT”, mysql_error());

My die() function looks like: die(DIEOUTPUT);

Is this possible to do?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T08:31:02+00:00Added an answer on June 15, 2026 at 8:31 am

    No, that is not possible.

    Instead, you could create your own version of die():

    function my_die(){
        if($is_production_environement) {
            die("An error has occured");
        }
        else{
            var_dump(mysql_error());
        }
    }
    

    Note:

    • You should consider moving away from mysql_* functions to PDO or mysqli.
    • Using die() (or my_die() for that matter) on a real webpage is not too userfriendly, consider alternatives
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to write a web application and want to use Ruby. I have
I have an existing web application that I am converting to use CakePHP. The
I am designing a web application using php and mysql. I have a little
Recently, I wrote a simple web application. I currently have. A static page which
I have a Master - Slave setup for a web application written in PHP.
I have a PHP web application developed using symfony framework. I want to call
I'm writing a php web application using Yii and need to use C++ (will
I have a tomcat web application.Is it possible to create a folder / write
I have created blank Asp.Net-MVC 3 web application and want to write my own
I have web application written in java using Eclipse. It has just one servlet

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.