Sabtu, 15 September 2012

Koneksi PHP ke DB

cara 1:
<koneksi.php>
<?php
$a = mysql_connect("localhost","root","pass");
$b = mysql_select_db("test",$a);
?>

cara 2:
<koneksi.php>
<?php
$a = "localhost";
$b = "root";
$c = "pass";
$d = "test";

$e = mysql_connect($a,$b,$c);
$f = mysql_select_db($d,$e);
?>

*penjelasan
$a = dibaca variabel a.
mysql_connect = dihubungkan ke mysql.
localhost = server mysql.
root = user mysql,biasanya root.
pass = pass mysql,jika ada. biasanya kosong.
mysql_connect_db = dihubungkan ke mysql database dengan nama database tersebut.

Tidak ada komentar:

Posting Komentar