How to connect to a database using PHP code?

Asked By 0 points N/A Posted on -
qa-featured

I am using XAMPP as my web server and Coffee cup software for coding. My task for our project is to formulate PHP codes for our simple website. What particular PHP code shall I use to connect to a database?

SHARE
Answered By 0 points N/A #163187

How to connect to a database using PHP code?

qa-featured

Hi Janine,

Since you are using xampp server, I'll assume your database is MySQL. PHP can connect to a mysql database in a pretty simple way. What you need to have is your login details of your xampp server. Supply this details to a function called mysql_connect which will connect you mysql database. 

Download the code below and edit to a php file edit as required and run it. you are now connected to a mysql database. You can then issue commands to the database.

Thanks,

Ford Smithkings

Related Questions