Hi This is the most confusing. I tried experimenting with type string, number and bit.
I found the most accurate - the bit type(TRUE and FALSE).
Here's what I found after testing in another file php:-
try
{
$dbh = new PDO($dsn, $user, $pswd, array(PDO::ATTR_TIMEOUT => "10",// 10 seconds
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)); // connect to DB, declared as global variable!
$firephp->warn("Attempting to login and connect to server is successful.");
$connect = TRUE;
}
catch(PDOException $err)
{
$firephp->error("Attempting to use selected database is failed.");
$alertmsg = $err->getMessage();
$firephp->log($err);
$connect = FALSE;
They are workable and I then amend the old code below as shown :-
$.ajax// use of jQuery here
({
type: "POST",
url: "testconnect.php",
data: {nameDB: dbValue},
success: function(connect)// meant for ajax request purposes only, not 500 interval server error!
{
console.debug("data read as: ", connect);
if(connect)//as true or false as indicated in login.php
alert("Successfully login and connected");
else
alert("Attempt to login and connect is NOT successful");
},
Where the "success" is concerned, It is only applicable to Database whether it is successful or or not, I would use the code as above. Whatever the result, "connect" would be read as '11' as TRUE and '' as FALSE.
This way, it is less confusing and straight forward.
And finally for the error, It ia applicable to ajax errors only, not database's status.
I would code it like :-
error: function(xhr, textStatus, error)// for only ajax errors, nothing to do w
{
console.debug(xhr.statusText);
console.debug(textStatus);
console.debug(error);
}
Thank you for your help. All are working. However I have yet to test Ajax errors. How do I simulate ajax errors?