How to Connect php with mysql Database

1104 0

$1*/ mo hosting! Get going with GoDaddy!


Code for mysql connection with php

1. In the below  we can deifne our host name. For local you can use localhost. If you want to acces the other host then put that host  name or Server IP here

2.This code for db user name. For local we use root. But you can create  db user name whatever you want.

3. Here we can define db password. For local you should leave blank.

4.Here we define our  database name

5. mysql_connect is a in built function for connect to mysql Database

6.For perform operationon database, we need to select database. By using mysql_select_db

Note : die use for print a message and exit the current script.

In this article

Join the Conversation


Share