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

  • Home
  • SEARCH
  • 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 6695911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:16:43+00:00 2026-05-26T06:16:43+00:00

My JS function expects a certain return from the PHP code in case of

  • 0

My JS function expects a certain return from the PHP code in case of a failure.

function showResult(data) 
{
    if (data == 'save_failed') {
        document.getElementById('result').innerHTML = 'Unfortunately, we were not able to save your information. Please contact an admin.';
        return false;
    } else {
        $("#notify").clearForm().clearFields().resetForm();
        document.getElementById('result').innerHTML = 'Thank you for signing up with us.';
        return false;
    }
}

This works fin when I echo 'save_failed'; in case of an explicit error, but it does not work in the case of die statements, such as this one:

mysql_connect("host", "user", "pass") or die('save_failed');

I entered a wrong hostname but the JS function did not receive the 'save_failed' return.

PHP script:

if (!(empty($_POST['name']) && empty($_POST['email'])))
    {
        //sanitizing inputs for MySQL insertion
        $name = mysql_real_escape_string($_POST['name']);
        $email = mysql_real_escape_string($_POST['email']);

        //connecting to db
        mysql_connect("host", "user", "pass") or die('save_failed');
        mysql_select_db("table") or die('save_failed');

        //inserting into table
        mysql_query("INSERT INTO notify (name, email) VALUES('" . $name . "', '" . $email . "' ) ") 
        or die('save_failed');  

    }
    else
    {
        echo 'save_failed';
    }
  • 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-05-26T06:16:44+00:00Added an answer on May 26, 2026 at 6:16 am

    Even though die("save_failed") will output “save_failed”, it will not stop any previous output in your script from being sent.

    Ensure that if you go to the script yourself then you are receiving just “save_failed” in the page source and no erroneous characters

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a function that expects real numbers (either integers or floats) as its
I have a control that has a Filter property that expects a function that
symbol.c: In function 'symbol_FPrint': symbol.c:1209: warning: format '%ld' expects type 'long int', but argument
I'm using a Python API that expects me to pass it a function. However,
function returnsAnArray () { return array ('test'); } echo returnsAnArray ()[0]; generates a syntax
function Submit_click() { if (!bValidateFields()) return; } function bValidateFields() { /// <summary>Validation rules</summary> ///
I'm trying to access the width of certain elements by using jQuery's .width() function,
In some C++ code, I use integers to store lots of changing data. To
My function expects a list or a tuple as a parameter. It doesn't really
Say I have two functions that expect ...rest parameters private function a(...myParams):void { trace(myParams.length);

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.