Skip to content

Instantly share code, notes, and snippets.

@333crist
Last active January 26, 2018 18:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 333crist/c22912e051550e2080abde8ec269bfd4 to your computer and use it in GitHub Desktop.
Save 333crist/c22912e051550e2080abde8ec269bfd4 to your computer and use it in GitHub Desktop.
koneksi
<?php
//Ini adalah Sample syntax format PHP Versi diatas 5
$db_host = "localhost"; //variable tentang isian host
$db_user = "root"; //variable tentang isian user
$db_pass = ""; //variable tentang isian password
$db_name = "database_anda"; //variable tentang isian database
$conn = mysqli_connect($db_host, $db_user, $db_pass, $db_name);
if(mysqli_connect_errno()){
echo 'Koneksi gagal! : '.mysqli_connect_error();
}else{
echo 'Koneksi berhasil';
}
?>
<?php
//Ini adalah Sample syntax format PHP Versi 5
$db_host = "localhost"; //variable tentang isian host
$db_user = "root"; //variable tentang isian user
$db_pass = ""; //variable tentang isian password
$db_name = "database_anda"; //variable tentang isian database
$conn=mysql_connect($db_host, $db_user, $db_pass);
$result=mysql_select_db($db_name);
if ($result)
{
echo "Database Ada";
}
else
{
echo "Database Tidak Ada";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment