note 87026 rejected from language.operators.logical by danbrown
| From: | danbrown@php.net | Date: | Sun, 16 Nov 2008 17:46:54 +0000 |
| Subject: | note 87026 rejected from language.operators.logical by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-146602@lists.php.net to get a copy of this message | ||
Note Submitter: loaded67 at hotmail dot com
----
Dear sandaimespaceman at gmail dot com
You are putting some really, really bad practice into use here!
die() and exit(); kill your script!
Which in most cases should be avoided as much as possible.
It does not provide any advantages whatsoever!
Even worse is suppressing errors with @ unless you can replicate the errors yourself.
However your example is horrible!
Let's take a look at http://www.php.net/mysql_connect
it says at the return values:
"Returns a MySQL link identifier on success, or FALSE on failure. "
I assume you want to know what went wrong if the connection fails, so you can fix it.
<?php
$connection = @mysql_connect($host, $user, $pass);
if(!$connection){
echo 'connection failed: '.mysql_errno($connection).' =>
'.mysql_error($connection).'<br />'.PHP_EOL;
}
else{
//connected, proceed!
}
?>
Hence you get a message instead of killing your complete application and wondering where it all went
wrong....
Very bad practice to use exit() or die here!
This is more related to mysql_connect then Logical Operators by the way.
Admins should remove your post IMO.