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

avatar DhikaRachman
@DhikaRachman

1 Kontribusi 0 Poin

Diperbarui 6 tahun yang lalu

3 Jawaban:

itu belum kepilih db nya

avatar aipfery
@aipfery

4 Kontribusi 0 Poin

Dipost 6 tahun yang lalu

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."/";

avatar chaidiryahya
@chaidiryahya

139 Kontribusi 99 Poin

Dipost 6 tahun yang lalu


<?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 (^_^)

avatar ciloxz
@ciloxz

284 Kontribusi 139 Poin

Dipost 6 tahun yang lalu

Login untuk ikut Jawaban