Outbrain

Cara Connect Php ke Mysql

Cara Connect Php ke Mysql

Admin Post coding untuk connect ke mysql. just for my inform only..
sambil2 klu korang pham leh gak la belajar2 kan




//***  "die()" will exit the script and show an error if something goes wrong with the "connect" or "select" functions.
//***  A "mysql_connect()" error maksud connection salah
//***  A "mysql_select_db()" error maksud database xde.. =-=!
// Place db host name. Usually is "localhost" but sometimes a more direct string is needed
$db_host = "localhost";
// username untuk MySQL database
$db_username = "username connect ke mysql";
// password untuk MySQL database
$db_pass = "password conect ke mysql jika ada";
// nama untuk MySQL database
$db_name = "nama database";

mysql_connect("$db_host","$db_username","$db_pass") or die(mysql_error());
mysql_select_db("$db_name") or die("no database by that name");
?>




Test untuk Connect ke database jadi or x



include_once("connect.php");

echo "

yess korang dah dapat connect database kah3..
";
?>

Sumber : HAckPensil

0 ulasan: