Re: PHP-MySQL connection for particular module
| From: | Chris | Date: | Wed, 18 Jun 2008 23:57:56 +0000 |
| Subject: | Re: PHP-MySQL connection for particular module | ||
| References: | 1 2 3 4 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-45088@lists.php.net to get a copy of this message | ||
Isaak Malik wrote:
> Because then the connection resource isn't stored in the $link variable
> and you will be able to use the mysql functions without passing that
> variable to each function.
RTM again.
The link parameter is completely optional.
If you don't specify it, it uses the last connection created.
I can do this and it's perfectly valid:
$link = mysql_connect($server, $user, $pass);
if (!$link) {
die ("Unable to connect to the database server");
}
$db_selected = mysql_select_db($databasename);
if (!$db_selected) {
die("Unable to connect to the database $databasename");
}
$result = mysql_query("select 1");
--
Postgresql & php tutorials
http://www.designmagick.com/