Re: connecting to mysql db
| From: | skate | Date: | Tue, 25 Mar 2003 14:02:48 +0000 |
| Subject: | Re: connecting to mysql db | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-140960@lists.php.net to get a copy of this message | ||
leaving the connection open creates security questions, and also leaves resources open, what if a
user closes his browser window, how do you know to close the connection?
if you really want to make it simple, you can edit your php.ini to have the username and password as
default in there, but again, this can be a security risk.
i'm afraid the best way is to include connection code on every page...
--
skate - fatcuban.com
"Iggy" <ifran@winegard.com> wrote in message news:20030325135847.77144.qmail@pb1.pair.com...
> This really doesn't explain me much. I mean the difference between having
> that code on every page or calling it from an external page doesn't tell me
> if it is realy necessary to do it all the time. I guess I am looking for
> more generic explanation of the whole process rather than what you said.
>
> However I appreciate it much, since it seems to be much better coding
> practice
>
> Iggy
>
>
>
> "Randy Rankin" <randy.rankin@invensys.com> wrote in message
> news:F3BF649E168BD411A1B700010271F38B014255F4@SBMAIL...
> > Place the code in a file ( ie; dbcon.php ) and include that file in any
> page
> > which may need it using an include statement: include("dbcon.php");
> >
> > Randy
> >
> > -----Original Message-----
> > From: Iggy [mailto:ifran@winegard.com]
> > Sent: Tuesday, March 25, 2003 7:50 AM
> > 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
> >
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>