calling some other php file from php file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • harintfs
    New Member
    • Dec 2011
    • 17

    calling some other php file from php file

    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....li ke that...

    is it possible? pls help me. advance thanks.
  • matheussousuke
    New Member
    • Sep 2009
    • 249

    #2
    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.:
    Code:
    <?  include 'yourfolder/yourfile.php'; ?>

    Comment

    • matheussousuke
      New Member
      • Sep 2009
      • 249

      #3
      but if you just want to load the file, for example, a configuration file, use require_once instead of include.

      Comment

      • omerbutt
        Contributor
        • Nov 2006
        • 638

        #4
        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

        Comment

        • harintfs
          New Member
          • Dec 2011
          • 17

          #5
          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

          Comment

          • omerbutt
            Contributor
            • Nov 2006
            • 638

            #6
            well you can use fopen to create / write to a file
            Code:
            $myFile = "testFile.php";
            $fh = fopen($myFile, 'w') or die("can't open file");
            $stringData = '<?php $message="Hi how are you \n";
            echo $message."\n";?>';
            fwrite($fh, $stringData);
            fclose($fh);
            and then you can call that file via calling
            Code:
            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

            Comment

            Working...