Jumat, 06 Juni 2014

PHP Connection Snippet

I often forget about this, I bet you often forget about this too. Yeah, this only happens once in programming. Especially this happen when you write your application without a framework.

Here it the snippet, you can copy - paste into your code.


<?php
$my['host']    = "localhost";
$my['user']    = "root";
$my['pass']    = "password";
$my['dbs']    = "database_name";

$connect    = mysql_connect($my['host'], $my['user'], $my['pass']);
if (! $connect) {
  echo "Connection Fail..!";
  mysql_error();
}

// CHOOSE THE DATABASE
mysql_select_db($my['dbs'])
     or die ("Can't find the database ".mysql_error());
?>

Tidak ada komentar:

Posting Komentar

Cara Mengetahui Besar Database PostgreSQL Tanpa Mendownloadnya

Berikut adalah langkah-langkah untuk mengetahui ukuran semua database di instance PostgreSQL yang berjalan di dalam kontainer Docker: 1. Men...