The beauty of PHP programming is its easy way of estabishing a connection with the database.
Following code snippet shows how to connect to mysql database in windows environment.
// my username is root and password is blank.
$con=mysql_connect("localhost",''root"," ");
if (!$con)
die ("Unable to establish a connection");
/*now we connect to database.
My database name is mydb */
$db=mysql_select_db("mydb");
if (!$db)
die ("Database not found");
// now proceed with building query.
?>
Feel free to ask if you have any questions.
No comments:
Post a Comment