Connections to mySQL

Codes here !

Moderators: macek, egami, gesf

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

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

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

<?php
$db = mysql_connect($host,$user,$pass);


//first script
mysql_query($query,$db);

//second script
mysql_query($query, $db);
?>

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

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: Google [Bot] and 1 guest

cron