Page 1 of 1

Mulitple users (scripts) same login? Is this a problem

Posted: Fri Mar 02, 2007 4:55 am
by Kadanis
Hi

Hope someone can help.

I have numerous PHP scripts that all access the same database, so I used the same username and password each time a connection was needed.

Now I have started to run some processes via cron and there is a recurring situation where more that 1 script will run at the same time and try to access the database.

My question is, would this be a problem, i.e would one script kick another one out if they are both using the same log in at the same time to access the same database. Should I be providing each script with its own user name, password and access rights?

The reason I ask is that I've started noticing some funny behaviour since this situation arose and I wondered if this was the cause.

Thanks in advance for any replies ;)

Posted: Fri Mar 02, 2007 6:50 am
by s.dot
That's not a problem.

When you connect to a database, by let's say mysql_connect(), a link to that database is created. If a new script runs (whether it's on a cron or not) it will establish a new link to the database. Two links, two scripts, same database = no problem.

Posted: Fri Mar 02, 2007 7:06 am
by Kadanis
even if they have the same login details. like the two examples below running concurrently.

Code: Select all

/** 
 *script 1
*/

$mysql = mysql_connect('localhost','user1','pass1');
mysql_select_db('my_db');

//do somthing

mysql_close($mysql);


/**
 * script 2
*/
$mysql = mysql_connect('localhost','user1','pass1');
mysql_select_db('my_db');

//do somthing else

mysql_close($mysql);

Posted: Fri Mar 02, 2007 9:01 am
by mikeq
no problem at all.

Posted: Fri Mar 02, 2007 9:18 am
by s.dot
I use one connection for all of my scripts across the whole website (hundreds of pages). I'm sure a lot of these connections are made simultaenously, and I have no problems at all.

Posted: Fri Mar 02, 2007 10:20 am
by Kadanis
ok. cool.

thanks for the answers.

will have to broaden the bug search :)