Hi Guys I've now sorted the sql query and the database is now sorted, but now I want to connect the PHP and sql database

Config.php file

//Mysql Connect  |   mysql_connect("host","username","password");
//Below example to connect in localhost
$a=mysql_connect("localhost","root","");

//select your database
$b=mysql_select_db("database_name",$a);

I take it I need to specify the "host", "username" and "password" on phpmyadmin this is where the info is I take it? and I also need to specify the "dababase" name

Any help would be brilliant

Recommended Answers

All 5 Replies

On this link you can see connecting to database with host, username, password and database.

hey milil thanks for the replay i will look at this thanks so much

i need to define what the password and etc is to let the sql to connect?

Yes, on the link you have examples for "mysqli" and "mysql" connect they both work but if you have older versions of PHP server use "mysql" connect.

mysql_connect("host", "admin", "password") or die(mysql_error()); 

First you defind your host that is address from your server.
"admin" is your user who have access to database and "password" is your password for database. If you didn't put any password, they can be blank in many cases...
Then you connect to your database schema:

mysql_select_db("name_of_database") or die(mysql_error()); 

and then you can do some sql queries...

$data = mysql_query($sql) or die(mysql_error());

thanks milil for the advice :) its much apreicated

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.