A couple questions from a newbie
Posted: Sat Nov 16, 2002 6:50 am
Hi,
I'm converting my ASP site to PHP with MySQL, and I've been encountering some problems, as I have just started with PHP. Some of them have been solved after searching and reading lots of sites and tutorials. But others don't.
Basically, I have a page that has around 1.300 lines of code, with only functions. Functions for searching a nickname, the number of posts of an user, the forum tittle, the avatar, etc. Now I am converting that file to PHP, but I have a problem.
I made a "testphp.php" page referencing those functions I'm slowly converting, but each load of the page is *very* slow. I test it in a localnetwork with my ADSL connection. The "server" is a PII 233 with 64Mb RAM, running Win2000 with MySQL (with the FoxServ package). My main question is: Am I doing right including this "functions.php" file? Is it too big? Should I change my working style?
On another topic, with the ASP I used to open all the database connections in the global.asa file, when the whole application (website) is started, so in each database access I only needed to switch to the right connection, like "set active conection to xxxx". So only ONE conecction is opened always, regardless of the users accesing the site. But now with PHP I find nothing about Application object, or about a global connection.
I heard that MySQL closes connections but... Can I set a "global" connection instead of using mysql_connect statement in each file (even with an included file).
Or can I just add a function with something like this?
function sConnect($pDatabase)
{
mysql_connect("host","user","pass");
mysql_select_db($pDatabase);
}
So this way, I only have to use:
sConnect("forums");
Is this possible?
Oh... and another "small" doubt. That function file contains the connect and select_db statement on each function. Does the server try to run that to check if is right each time? Or does it only connect when I call the function?
Is just that is getting too strange to me to set a connection with each function.
And for ending this message, I would like to ask about "Active visitors". With ASP I use the global.asa file to add 1 to the Session variable that contains the value but... no global.asa in PHP... what is the equivalent file, if any?
Thanks for any answers.
I'm converting my ASP site to PHP with MySQL, and I've been encountering some problems, as I have just started with PHP. Some of them have been solved after searching and reading lots of sites and tutorials. But others don't.
Basically, I have a page that has around 1.300 lines of code, with only functions. Functions for searching a nickname, the number of posts of an user, the forum tittle, the avatar, etc. Now I am converting that file to PHP, but I have a problem.
I made a "testphp.php" page referencing those functions I'm slowly converting, but each load of the page is *very* slow. I test it in a localnetwork with my ADSL connection. The "server" is a PII 233 with 64Mb RAM, running Win2000 with MySQL (with the FoxServ package). My main question is: Am I doing right including this "functions.php" file? Is it too big? Should I change my working style?
On another topic, with the ASP I used to open all the database connections in the global.asa file, when the whole application (website) is started, so in each database access I only needed to switch to the right connection, like "set active conection to xxxx". So only ONE conecction is opened always, regardless of the users accesing the site. But now with PHP I find nothing about Application object, or about a global connection.
I heard that MySQL closes connections but... Can I set a "global" connection instead of using mysql_connect statement in each file (even with an included file).
Or can I just add a function with something like this?
function sConnect($pDatabase)
{
mysql_connect("host","user","pass");
mysql_select_db($pDatabase);
}
So this way, I only have to use:
sConnect("forums");
Is this possible?
Oh... and another "small" doubt. That function file contains the connect and select_db statement on each function. Does the server try to run that to check if is right each time? Or does it only connect when I call the function?
Is just that is getting too strange to me to set a connection with each function.
And for ending this message, I would like to ask about "Active visitors". With ASP I use the global.asa file to add 1 to the Session variable that contains the value but... no global.asa in PHP... what is the equivalent file, if any?
Thanks for any answers.