membuat file koneksi php di beberapa macam database

Posted on Updated on


baiklah sekarang saya akan memposting cara membuat file koneksi atau file configurasi php di bebrapa macam database antara lain oracle , mysql , sql server  , postgree sql , ino DB , Ms Acssess .oke tanpa harus berkoak koak ane langsung puter ne lagu hahahahah chechidot….

koneksi php di database Oracle :

<?php
//membangun koneksi
$username="belajar";
$password="belajar";
$database="localhost/orcl";

$koneksi=oci_connect($username,$password,$database);

if($koneksi){
echo "Koneksi berhasil";
}else{
$err=oci_error();
echo "Gagal tersambung ke ORACLE". $err['text'];
}
?>

koneksi php di database mysql :

<?php
 $server = “localhost”;
 $username = “root”;
 $password = “”;
 $database = “coba”;
 mysql_connect($server,$username,$password) or die(“Koneksi gagal”
 mysql_select_db($database) or die(“Database tidak bisa dibuka”
 ?>

koneksi php di database Sql Server:

<?php
//membangun koneksi
$username="user";
$password="password";
$database="coba";

$koneksi=mssql_connect($username,$password,$database);

?>

koneksi php di database Postgree Sql :

<?
 $conn_string = "host=localhost port=5432 dbname=dbcoba user=postgres password="";
 $connection = pg_pconnect($conn_string);
 if (!$connection) {
 print("Connection Failed.");
 exit;
 }
 else
 print("Connection Success.");
 ?>

koneksi php di database Ms Acssess:

<?php
$konek=odbc_connect("Data","","");
if(!$konek)
{
   die("gagal");
   odbc_close($konek);
}
else
{
   echo ("Koneksi Berhasil");
}
?>

selesaiiiiii
happy coding

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s