Koneksi PHP MySQL





MySQL sangat sering digunakan bersama-sama dengan PHP.

Koneksi ke database MySQL

 

mysql_connect(servername,username,password);

Parameter
Description
servername
Optional. Specifies the server to connect to. Default value is "localhost:3306"
username
Optional. Specifies the username to log in with. Default value is the name of the user that owns the server process
password
Optional. Specifies the password to log in with. Default is ""

Program23-1.php
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
// some code
?>


Menutup Koneksi

 

Program23-2.php
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
// some code
mysql_close($con);
?>

0 komentar:

Post a Comment

Copyright © 2014 Dunia Naeta All Right Reserved