Else statement to show connection successful [closed]
- by Craig Smith
I am trying to write a script to test a database connection, at the moment it will only display text if the connection doesn't work, I am stuck with trying to create an else statement to display "Connection Successful" if it works.
Here's my code so far. Any help appreciated :)
<?
$conn = @mysql_connect("localhost", "root", "");
if (!$conn) {
die("Connection failed: " .mysql_error());
}
?>