This is a very useful piece of script, somehow these days MySQL gives depreciating error as PDO has replaced it.Though it hasn't been officially deprecated - due to widespread use - in terms of best practice and education, it might as well be. Please search for PDO DB connection script in this blog under Project and Script.
<?php
/**
* Created by PhpStorm.
* User: wao
* Date: 1/26/2015
* Time: 4:28 PM
*/
$mysql_hostname = "localhost"; /* replace it with your host [In most case the host name is same "localhost"] */
$mysql_user = "root"; /*It is a default username in your MySQL if you have set manual users please replace "root"*/
$mysql_password = "";/*It is a default password in your MySQL if you have set manual password please replace ""*/
$mysql_database = "blog"; /* insert your database name here*/
$bd = mysql_connect($mysql_hostname, $mysql_user, $mysql_password)
or die("Opps some thing went wrong, couldnot connect to the database");
mysql_select_db($mysql_database, $bd) or die("Opps some thing went wrong, cannot select database");
?>
No comments:
Post a Comment