PDA

View Full Version : How do you connect a phpmyadmin database to a website page please ?


Saz
10-24-2006, 09:53 AM
Hi, Can anyone please give a little help on phpMyAdmin please ? I've worked with websites for a few years, but have never been involved with databases.

I've managed to create a database in my phpMyAdmin - the versions are below:

phpMyAdmin - 2.8.0.2

* MySQL client version: 4.1.10
* Used PHP extensions: mysql

After I created the database, it gave me some code below, but am not sure what the next few steps are:

PHP $dbh=mysql_connect ("localhost", "practice_saz", "<PASSWORD HERE>") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("practice_test");

Any help appreciated.

Saz.

Shoot2Kill
10-24-2006, 11:07 AM
ok, you have created a database called practise_test, and your phpMyAdmin has given you the code that you need to enter into your PHP script to connect to this database...


$dbh=mysql_connect ("localhost", "practice_saz", "<PASSWORD HERE>")//THIS CONNECTS TO THE SERVER WITH YOUR DETAILS
or die ('I cannot connect to the database because: ' . mysql_error());//IF IT CANNOT CONNECT, THIS ERROR MESSAGE WILL SHOW
mysql_select_db ("practice_test");//THIS SELECTS THE CORRECT DATABASE FROM YOUR SERVER


IS THIS WHAT YOU WANTED.. ???

guelphdad
10-24-2006, 02:23 PM
Did you check the manual at php.net specifically the mysql area of the manual?