Connections to mySQL

Codes here !

Moderators: macek, egami, gesf

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

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
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA

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);

New php-forum User
New php-forum User
Posts: 2
Joined: Wed Nov 06, 2002 4:02 am

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...

Return to “mySQL & php coding”

Who is online

Users browsing this forum: No registered users and 2 guests