mysql_connect() with a multi-file format

From: Date: Wed, 22 Jun 2005 15:18:22 +0000
Subject: mysql_connect() with a multi-file format
Groups: php.db 
Request: Send a blank email to php-db+get-39745@lists.php.net to get a copy of this message
I'm new to PHP, due to having been all hard-nosed and obtuse about using Perl/CGI. I've been looking for a good way to pick up php tricks and what-nots, so I joined the list. That said, I have an immediate question. I have a multi-file script: main.php requires_once config.php, and so on. I'd like to have a data.php file that handles function wrappers for database and also establishes a connection to the db. I read in the php.net manual that the connection closes automatically when the script exits. Does this mean I can't open a db connection in one file and pass the link around from function to function? ie: require_once 'data.php'; // data.php contains a mysql_connect() // after this line, is my link closed? require_once 'blah.php' ; OR: require_once 'data.php'; // with wrapper data_connection() $save_this_link = data_connection() ; // will this work? some_function( $save_this_link ) ; //etc. -- Douglas Hernandez (612) 229-9684

« previous php.db (#39745) next »