RE: [PHP] connecting to mysql db
| From: | Mirco Ellis | Date: | Tue, 25 Mar 2003 14:17:08 +0000 |
| Subject: | RE: [PHP] connecting to mysql db | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-140958@lists.php.net to get a copy of this message | ||
This is the only way I know and probably the safest. This way you know there
is connectivity because it is loaded rigth at the beginning.
Mirco Ellis
I-Soft Solutions
e-mail: mirco.ellis@isoftpe.co.za
Tel: +27414847161
-----Original Message-----
From: Igor Frankovic [mailto:ifran@winegard.com]
Sent: Tuesday, March 25, 2003 16:03
To: mirco.ellis@isoftpe.co.za
Subject: RE: [PHP] connecting to mysql db
But is it always necessary to do this or can you open this connection once
and have it open throughout the next few pages (or as needed) and then close
it?
> -----Original Message-----
> From: Mirco Ellis [mailto:mirco.ellis@isoftpe.co.za]
> Sent: Tuesday, March 25, 2003 8:00 AM
> To: 'Iggy'
> Cc: Php-General (E-mail)
> Subject: RE: [PHP] connecting to mysql db
>
>
> No dude. Create a file called whatever.inc that includes the
> code that you are using to connect to the db. In every php
> script ,that needs this connection to the db, you simply put:
>
> <?php
> include("whatever.inc");
> ?>
>
> Mirco Ellis
> I-Soft Solutions
> e-mail: mirco.ellis@isoftpe.co.za
> Tel: +27414847161
>
>
> -----Original Message-----
> From: Iggy [mailto:ifran@winegard.com]
> Sent: Tuesday, March 25, 2003 15:50
> To: php-general@lists.php.net
> Subject: [PHP] connecting to mysql db
>
>
> hi,
> I am trying to play and learn php along with mysql and I have
> a question about connecting to a db. Is the following code
> necessary on every php page where I am retrieving some data
> from a db or is there any way to connect once (something like
> index.php) and have that connection open through subsequent
> pages? the code <?php $link = mysql_connect("localhost", "",
> "")
> or die("Could not connect: " . mysql_error());
> print ("Connected successfully");
>
> mysql_select_db("test")
> or die("Could not select database: " . mysql_error()); ?>
>
> thanx
> iggy
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>