954,157 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to connection string into a dictionary in php code and vice versa

hai i am sathiya,
i had confussion about this program...................
please give suitable solution for this program............

a. Write a php function to accept server, database name, Username Password and create a Database connection string of the
"server=myserver;dbname=mydbname;username=myuser;passwd=mypasswd"

b. Write a function to convert the connection string into a dictionary

c. Write a function convert the connection dictionary into connection string.

r_sathya
Newbie Poster
18 posts since Oct 2008
Reputation Points: 9
Solved Threads: 0
 

Wow, that's kind of confusing. What do you mean by a dictionary?

No one here will write your code for you but we will point you in the right direction.

Here is a good place to start (you'll want to make sure you look at the "POST & GET" section).

As for connecting the info together when you have it, it's as simple as:

$connected_string = "server=$myserver;dbname=$mydbname;username=$myuser;passwd=$mypasswd";
//or alternatively:
$connected_string = 'server='.$myserver.';dbname='.$mydbname.';username='.$myuser.';passwd='.$mypasswd;
//where the info you want is held in the variables $myserver, $mydbname, etc.
humbug
Junior Poster in Training
93 posts since Oct 2005
Reputation Points: 20
Solved Threads: 13
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You