Wednesday, May 29, 2013

Simple PHP code to connect MySQL database

$link = mysql_connect("localhost", "root", "")

        or die("Could not connect");

$db = mysql_select_db("db_name", $link)
or die("Could not select database");

//localhost is the host name of the sever
//root is the database user name