Query couldn't be executed

Query [SELECT * FROM tb_karyawan WHERE username='Abdul' AND password='827ccb0eea8a706c4c34a16891f84e7b'] couldn't be executed

Fatal error: Uncaught TypeError: mysqli_error(): Argument #1 ($mysql) must be of type mysqli, int given in C:\xampp\htdocs\Absensi\karyawan\pro_login_karyawan.php:13 Stack trace: #0 C:\xampp\htdocs\Absensi\karyawan\pro_login_karyawan.php(13): mysqli_error(0) #1 {main} thrown in C:\xampp\htdocs\Absensi\karyawan\pro_login_karyawan.php on line 13

INI KODINGANYA

<?php
  include_once "../koneksi.php";

  $username = $_POST['username'];
  $pass = md5($_POST['password']);
  $sql = "SELECT * FROM tb_karyawan WHERE username='$username' AND password='$pass'";
  $login= mysqli_query($koneksi,$sql);
  $result2=0;
  $conn=0;
  if (!$result2) {
    echo "<p> Query [$sql] couldn't be executed </p>";
    echo mysqli_error($conn);
}

  $ketemu=mysqli_num_rows($login);
  $b=mysqli_fetch_array($login);

  if($ketemu>0){
    session_start();
    $_SESSION['idsi']   = $b['id_karyawan'];
    $_SESSION['usersi'] = $b['username'];
    $_SESSION['namasi'] = $b['nama'];
    $_SESSION['ttlsi']  = $b['tmp_tgl_lahir'];
    $_SESSION['jenkelsi'] = $b['jenkel'];
    $_SESSION['agamasi'] = $b['agama'];
    $_SESSION['alamatsi'] = $b['alamat'];
    $_SESSION['teleponsi'] = $b['no_tel'];
    $_SESSION['jabatansi'] = $b['jabatan'];
    $_SESSION['fotosi'] = $b['foto'];
    header("location: index.php?m=awal");
}else{

    echo '<script language="javascript">';
        echo 'alert ("Username/Password ada yang salah, atau akun anda belum Aktif")';
    echo '</script>';
    header("location: login_karyawan.php");
}


 ?>

avatar alfinmahmud
@alfinmahmud

1 Kontribusi 0 Poin

Diperbarui 3 tahun yang lalu

1 Jawaban:

<div>coba cek php.ini di folder instalasi phpnya, mungkin blm di aktifkan extensionnya, atau bahkan blm terinstall sama sekali.</div>

avatar rubichandrap
@rubichandrap

25 Kontribusi 19 Poin

Dipost 3 tahun yang lalu

Login untuk ikut Jawaban