how can i connect to a database?

A

Anonymous

Guest
hi there all!!!>. gud day... can u help me how to connect a database to PHP... basically i dont really got any idea bout this.... ive just shift to PHP... from my past years i used ASP... now im trying to learn anyhow bout database programming with PHP... please tell me how? or u could give me a hand of code for this scipt...
 
Hi,

Check the following:

mysql_connect();
mysql_select_db();

Regards.
 
first you use one tools to connect , if connect was succeed , i write by PHP script.
 
Code:
<?

$db = array(

                "name" = "your_db_name",
                "user"   = "your_db_user",
                "pass"   = "your_db_pass",
                "host"   = "your_db_host");

mysql_connect('$db['host']','$db['user']','$db['pass']'); // connecting the db
mysql_select_db($db['name']); // selecting the db
?>


hopes it helps =]
 
Back
Top