1. No Profile Picture
    Devshed Newbie (0 - 499 posts)
    Dear friends

    I'm starting with PHP, and I have any questions:

    How interchange the values of global variables between different files of php's scripts?

    By example
    in file bdgeo.php3
    $bd contains the link to an open data base
    this file call to other file named b1.php3
    in file b1.php3
    $db is unknow!

    I think that the connection to the database should make only one time, in first script. In other way, How I maintain active the database connection among the different pages?

    Can somebody help me?

    Thank you
    Luis A. Gonzalez
  2. #2
  3. No Profile Picture
    Devshed Newbie (0 - 499 posts)
    Nope, you have to re-establish the database connection on the next page. In the background, PHP may be using a persistent connection, but that depends on configuration.

    Easiest way to do this is make an include file that has the database connection command(s) and then 'require("<file>.inc"); at the top of each script that needs a database.

    Then if anything ever changes (location of DB, name, etc), you only have to change the parameters once...

Similar Threads

  1. maysqladmin drop database syntax?
    By Slurm in forum MySQL Help
    Replies: 1
    Last Post: February 17th, 2004, 05:07 AM
  2. 2-dimensial array / mysql_fetch_array database problem
    By paulx82 in forum PHP Development
    Replies: 3
    Last Post: December 27th, 2003, 01:52 AM
  3. creating database & tables using ASP
    By pdxlooie in forum ASP Programming
    Replies: 2
    Last Post: December 26th, 2003, 05:27 PM
  4. question about request scope
    By pwbray in forum Java Help
    Replies: 1
    Last Post: December 17th, 2003, 02:25 PM
  5. distributing database reads among db slaves
    By JunkCookie in forum PHP Development
    Replies: 3
    Last Post: December 17th, 2003, 11:45 AM

IMN logo majestic logo threadwatch logo seochat tools logo