note 33925 deleted from function.mysql-select-db by didou
| From: | didou@php.net | Date: | Fri, 11 Jul 2003 08:10:49 +0000 |
| Subject: | note 33925 deleted from function.mysql-select-db by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-51890@lists.php.net to get a copy of this message | ||
Note Submitter: sonetti@hotmail.com
----
As an reply to jorik at scriptsnet dot nl with;
[quote]
<?PHP
mysql_connect("your host", "username", "password") or
die(mysql_error());
mysql_select_db("your database") or die(mysql_error());
?>
[/quote]
A better way to do this is;
<?php
if(!$db_conn = mysql_connect("your host", "username", "password"))
exit(mysql_error($db_conn));
else {
if(!mysql_select_db("your database", $db_conn))
exit(mysql_error($db_conn));
}
?>
You should always use the link identifier, and die() is just an alias for exit()