Postingan lainnya
mengatasi code php
Warning: mysqli_select_db() expects parameter 1 to be mysqli, string given in C:\xampp\htdocs\absenkampus\_db.php on line 10 Could not select database.
misi gan mau tanya bagaimana cara mengatasi perintah diatas ya gan
berikut isi coding saya :
$foldername="absenkampus"; $conn = mysqli_connect( $host, $user, $pass) or die('Could not connect to mysql server.' ); mysqli_select_db($dabname, $conn) or die('Could not select database.'); $baseurl="http://localhost/".$foldername."/";
mohon pencerahannya gan terimakasih
0
3 Jawaban:
nama dbnya belum terpilih.
mungkin harusnya gini gan :
$foldername="absenkampus";
$conn = mysqli_connect( $host, $user, $pass) or die('Could not connect to mysql server.' );
mysqli_select_db($foldername, $conn) or die('Could not select database.');
$baseurl="http://localhost/".$foldername."/";
atau gini :
$dabname="absenkampus";
$conn = mysqli_connect( $host, $user, $pass) or die('Could not connect to mysql server.' );
mysqli_select_db($dabname, $conn) or die('Could not select database.');
$baseurl="http://localhost/".$foldername."/";
0
<?php
$host ='localhost';
$user = 'root';
$pass = 'password nya';
$dabname = 'database nya';
$foldername = "absenkampus";
$conn = mysqli_connect( $host, $user, $pass) or die('Could not connect to mysql server.' );
/*
aturan => mysqli_select_db($koneksi, $database_nya);
mysqli_select_db($dabname, $conn) => kebalik
ganti
mysqli_select_db($conn, $dabname)
*/
mysqli_select_db($conn, $dabname) or die('Could not select database.');
$baseurl="http://localhost/" . $foldername . "/";
echo $baseurl;
?>
Semoga Bermanfaat ,, Happy Sharing (^_^)
0