For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > May 2004 > Passing vars into functions









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Passing vars into functions
jaquito13

2004-05-22, 6:30 am

I am working on a script that connects to MySQL databases using a
function. To initiate the function in the example below, I would type
the code --------
dbconnect('main').
--------I then want it to parse the user, host, and password into the
function from preset variables. I think that you get the picture.

Thanks for any help.


--------
main = "my_database";
main_user = "my_username";
main_pass = "my_password";
main_host = "localhost";

function dbconnect(database) {
db = ''.database;
user = db.'_user';
pass = db.'_pass';
host = db.'_host';
dbconnect = mysql_pconnect(eval(" host =
"host ";"),
eval(" user =
"user ";"),
eval(" pass =
"pass ";")) or die();
mysql_select_db
(eval(" db =
"db ";")) or die();

}
--------



----------------------------------------
The post originated from PHP
Freaks:
----------------------------------------
http://www.phpfreaks.com
http://www.phpfreaks.com/forums


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com