By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,204 Members | 1,360 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,204 IT Pros & Developers. It's quick & easy.

calling some other php file from php file

P: 17
hi,

I am having data base in MySql connecting with PHP. Working nice.
I have folder name "sales" where have all my php file.
I usually call sales/index.php from my html file.

As I am using shared hosting, which have limitation for MySql concurrent connection, which is limited to 200 connection.

To solve problem i created 5 database with same scripts.
And also I created 5 folders like same sales folder named sales2, sales3 ....sales5 to connect different dbs

(i have field in one table for total no of user using currently that database)

Here, I would like to create new Php file, and want to validate if database one have more than 150 user

i have to call sales2/index.php ... before calling that i have to verify is there enough room on second data base...or I have to call sales3/index.php....like that...

is it possible? pls help me. advance thanks.
Dec 2 '11 #1
Share this Question
Share on Google+
5 Replies


matheussousuke
100+
P: 249
omg, I didn't get you. What I know is: To load a php file inside another one and display it on the browser, you have to use --- include --

E.g.:
Expand|Select|Wrap|Line Numbers
  1. <?  include 'yourfolder/yourfile.php'; ?>
Dec 2 '11 #2

matheussousuke
100+
P: 249
but if you just want to load the file, for example, a configuration file, use require_once instead of include.
Dec 2 '11 #3

omerbutt
100+
P: 638
hi harintfs ,
first of all how do you determine how many user are currently usng the database you said you have a field in db that contains the number of user using the database, now is it for only 1 db or for all the dbs or every db has a different field where its number of current users are maintained , and how are you calculating and putting that figure for the number of users currently active?
regards,
Omer Aslam
Dec 3 '11 #4

P: 17
ya thanks for reply...
ya each db has userid (auto) & status for user whether he is online or not
...once user login his status ll be ;Y; at the time of logout or after 3 hrs his status ll be ;N;, so we can get count{id) where status ;Y;
.... If count more than 150 ... I have to call Sales2/index.php...b4 calling I have to verity whether db2 have enough room, otherwise Sales3/index.php.... like that....Adv thanks to soultion
Dec 3 '11 #5

omerbutt
100+
P: 638
well you can use fopen to create / write to a file
Expand|Select|Wrap|Line Numbers
  1. $myFile = "testFile.php";
  2. $fh = fopen($myFile, 'w') or die("can't open file");
  3. $stringData = '<?php $message="Hi how are you \n";
  4. echo $message."\n";?>';
  5. fwrite($fh, $stringData);
  6. fclose($fh);
  7.  
and then you can call that file via calling
Expand|Select|Wrap|Line Numbers
  1. header('testFile.php')
. i hope i am getting it right , this is what you want to achieve , by the way you can have the file by default created and you can put in the queries for the 3 / 4 how many DB there are and then at the runtime you just pass a parameter to check that DB by querying and moving on.
regards,
Omer Aslam
Dec 4 '11 #6

Post your reply

Sign in to post your reply or Sign up for a free account.