0

Koneksi PHP MySQL

Posted by Jujur Sitanggang on 5:28 AM


Bab 23

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 Comments

Copyright Jujur Soaloon Sitangang Lipan All rights reserved. Theme by Sitanggang. | Bloggerized by Soalparna.