Know thy all....

Friday, 4 September 2009

Connect to MySQL Database using PHP

The following script tries to connect the database and if it is failed it will display relevant message. The server is localhost and username/password combination is root/abc123. it is necessary to create a database ‘dummy’ before executing the script. Click here to set password for mysql and phpmyadmin

<?php

$con=mysql_connect(”localhost”,”root”,”abc123″) or die(”Couldnt Connect to database”);

$a=mysql_select_db(”dummy”,$con);

if($a)

echo “Database Selection Success”;

else

echo “Database Selection Failed”;

?>

0 comments:

Post a Comment

Pradeepkumar.org Copyright © 2011 | Template created by O Pregador | Powered by Blogger