Board index   FAQ   Search  
Register  Login
Board index php forum :: Database mySQL & php coding

Connections to mySQL

Codes here !

Moderators: macek, egami, gesf

Connections to mySQL

Postby digitalgravy » Mon Feb 17, 2003 9:28 am

If I have multiple php scripts in one page, and they all get info from my DB, do I have to connect to the DB for every script?, or can I use one connection in the first script and make my queries in the remaining scripts?

I appreciate any help.
User avatar
New php-forum User
New php-forum User
Posts: 32
Joined: Sat Feb 15, 2003 10:00 pm
Location: Los Angeles, CA

Postby Redcircle » Mon Feb 17, 2003 12:28 pm

you can make a connection and put the connection information into a variable and reference to it when you run the other script.
Code: Select all
$db = mysql_connect($host,$user,$pass);

//first script

//second script
mysql_query($query, $db);
User avatar
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA

Postby philipo » Tue Feb 18, 2003 10:28 am

Or you can use mysql_pconnect() function.

mysql_pconnect() always check if there's a connection already... you know...
New php-forum User
New php-forum User
Posts: 2
Joined: Wed Nov 06, 2002 4:02 am

Return to mySQL & php coding

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.