note 33925 added to function.mysql-select-db
| From: | sonetti at hotmail dot com | Date: | Fri, 11 Jul 2003 08:06:27 +0000 |
| Subject: | note 33925 added to function.mysql-select-db | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-51886@lists.php.net to get a copy of this message | ||
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()
----
Manual Page -- http://www.php.net/manual/en/function.mysql-select-db.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+33925
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+33925&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+33925&report=yes