MySQL Forums
Forum List  »  PHP

Cannot force stop script with die() ???
Posted by: Arthur Chan
Date: November 09, 2018 10:12PM

Cannot terminate script with die();

What the script is supposed to do:
Check for valid identifiers fID and tID using sprocs
The sprocs execute correctly in mySQL workbench and mySQL cloud db.
The intention is to terminate the script if the user has enter wrong identifiers.

Why does the PHP script continue executing?

I noticed the echo' some text...' is not displayed in the Eclipse console
die('some error text'.sqli_error()); is displayed in the Eclipse console.
How do i display text in Eclipse console (for functional testing purposes)?

$con = mysqli_connect("localhost", "user", "pwd", "instance");
mysqli_set_charset( $con, "utf8mb4" );
if (mysqli_connect_errno($con)) {
die('Failed to connect to MySQL!' .mysqli_connect_error());
$cID= (int)$_POST['CID'];
$fID= (int)$_POST['FID'];

$test1 = "call sp_getCId('$cID')"; // <= sproc to get value from database (type INT)
if ($test1 != (int)'$cID') {die('Wrong C_ID!');} // <= pointless to continue if C_ID is wrong!

$test2 = "call sp_getFId('$fID')";
if ($test2 != (int)'$fID') {die('Wrong F_ID!');} // <= pointless to continue if F_ID is wrong!

$result="call sp_setupFarm('$cI',''$fT')";

if(!mysqli_query($con, $result) ) {
die('PHP cannot insert data! ' . mysqli_error()); // <= Instead, the script stops here if the identifiers are wrong.
} else {
'Inserted successfully<br/>\n';

Options: ReplyQuote

Written By
Cannot force stop script with die() ???
November 09, 2018 10:12PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.