Howdy, guys... π
PHP newbie here trying to check if the given MySQL database exists or not so that I could return the result back to Flash MX on Windows 2000 Pro...
Here is what I want to do...
I want to see if the connection to the MySQL server has been established... Return '11' back to Flash if it fails...
See if the database exists and return '21' back to Flash if not...
I can use mysql_select_db() to see if the database exists, but I don't know what I can do with the connection to server... I don't see any return values from mysql_connect(), yet I get "Resource id #1" when I execute the script...
Is there any way I can know if the MySQL server connection exists with PHP???
Here is the script that I have used...
<?
include ('Include.inc');
$connectionServer = @mysql_connect($DBhost,$DBuser,$DBpass) or die ("Error connecting to the server");
print($connectionServer);
$connectionDatabase = @mysql_select_db("$DBName") or die ("Error retrieving user database");
print($connectionDatabase);
mysql_close($connectionServer);
?>
Right now, I get "Resource id #1" from print($connectionServer); and "1" from print($connectionDatabase);
I see that "Resource id #1" part will be varing depending on the connection... Should I just look for "Resource id" from the result and consider the connection is made if I get that substring??? Would there be any instance where it doesn't always say that the connection has been made???
One other question regarding this line...
$connectionServer = @mysql_connect($DBhost,$DBuser,$DBpass) or die ("Error connecting to the server");
Say that the connection is not made, then I will get "Error connecting to the server" and that string will be returned and printed out... Is it correct??? Just want to make sure of it... π
Appreciate any help...
Jason