use variable connection strings without eval?
Posted: Tue Sep 21, 2010 2:57 pm
I have multiple servers and I'm trying to have a user connect to the right server based on their 'assigned' server. So, I need to use different variable names based on that
in an include file earlier in the main script, I have...
in the main script, I have a variable that has the assigned server and I want to use the right connection variables based on this. I could use eval to turn $hostSignIn into $hostSignIn0001 (and so forth for the other variables) and then it would pull the right info, but I'm looking for an alternative way to do this since I'd like to exclude eval from functioning in my scripts using php.ini.
Is there an alternative way to do this without using eval?
Thanks.
in an include file earlier in the main script, I have...
Code: Select all
$hostSignIn0001="server1";
$userSignIn0001="xxx1";
$passwordSignIn0001="yyy1";
$dbnameSignIn0001="zzz1";
$hostSignIn0001="server2";
$userSignIn0001="xxx2";
$passwordSignIn0001="yyy2";
$dbnameSignIn0001="zzz2";
Is there an alternative way to do this without using eval?
Code: Select all
if (!$cxnSignIn = mysqli_connect($hostSignIn, $userSignIn, $passwordSignIn, $dbnameSignIn))
{ exit; }