Vars in Functions?
| From: | Pablo Fischer | Date: | Fri, 23 May 2003 21:26:56 +0000 |
| Subject: | Vars in Functions? | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-9597@lists.php.net to get a copy of this message | ||
HI!
Im including a php file with the include_php, However one of the functions
that I NEED to use.. I cant use it with PHP, the reason? Global vars, my
function:
function symp_connect() {
global $s_dbhost, $s_dbuser, $s_dbpass, $s_dbname;
global $s_dbid, $s_dbnum;
echo $s_dbuser;
if($s_dbid && $s_dbnum > 0) {
$s_dbnum = $s_dbnum + 1;
} else {
if($s_dbuser == "" && $s_dbpass == "") {
$s_dbid = mysql_connect($s_dbhost);
} else if($s_dbpass == "") {
$s_dbid = mysql_connect($s_dbhost, $s_dbuser);
} else {
$s_dbid = mysql_connect($s_dbhost, $s_dbuser, $s_dbpass);
}
if(!$s_dbid || !mysql_select_db($s_dbname, $s_dbid)) {
die("Unable to connect to the database!\n");
}
$s_dbnum = 1;
}
}
I dont know but I cannot use any global var in a function, However I need to
use functions (cause its a system poll), so exists a function that connects,
other than disconnects, etc.. so When I tries to connect it cant cause the
$s_dbhost and that global vars are empty :(.
And yes, I tried that BEFORE the functions include the php_file that contains
the var config names, but no results :(.
Sugestions?
Thanks!
Pablo Fischer