I have just migrated to V2023. I love it. (registered user)
I use the same script to connect to several DBs with the same structure. I would like to check if the DBname exists on the server before attempting the connection and customize the error message instead of getting the default DIE() message from PHPmaker.
I NEED HELP WITH THE CONDITION TO PUT IN JUST 1 LINE (the second IF statement)
// Database Connecting event
function Database_Connecting(&$info)
{
if(isset($_POST['db_id'])){
$_SESSION['db'] = 'db_name_'.$_POST['db_id'];
}
// I NEED HELP WITH THE CONDITION TO PUT IN THIS 1 LINE BELOW
if( ******The database $_SESSION['db'] does NOT exits****** ){
$_SESSION = array();
$_SESSION[SESSION_FAILURE_MESSAGE] = "Database ID not found";
return false;
}else{ $info["host"] = "locahost";
$info["user"] = 'root';
$info["password"] = 'password';
$info["dbname"] = $_SESSION['db'];
}
}
I simplified the code, but in real life I make sure that one User cannot switch to an unauthorized DB even if exist.