N/APosted on - 03/01/2013
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?
How to connect to a database using PHP code?
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.