error perintah koneksi.php

Warning: Use of undefined constant DIR - assumed 'DIR' (this will throw an Error in a future version of PHP) in C:\xampp\htdocs\pengiriman_barang\koneksi\koneksi.php on line 2

Warning: require_once(DIR/db_config.php): failed to open stream: No such file or directory in C:\xampp\htdocs\pengiriman_barang\koneksi\koneksi.php on line 2

Fatal error: require_once(): Failed opening required 'DIR/db_config.php' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\pengiriman_barang\koneksi\koneksi.php on line 2

syntax nya :

<?php

require_once  DIR . '/db_config.php';

$conn = new mysqli(DB_SERVER, DB_USER, DB_PASSWORD, DB_DATABASE);

if (mysqli_connect_errno()) { trigger_error('Koneksi ke database gagal: ' .

mysqli_connect_error(), E_USER_ERROR);

}

?>

avatar rockysimanjuntak_google
@rockysimanjuntak_google

1 Kontribusi 1 Poin

Diperbarui 2 tahun yang lalu

2 Jawaban:

<div>Mungkin Ada Kesalahan Di Sini Gan :&nbsp;</div><pre><strong>&lt;?php require_once DIR . '/db_config.php'; $conn = new mysqli(DB_SERVER, DB_USER, DB_PASSWORD, DB_DATABASE); if (mysqli_connect_errno()) { trigger_error('Koneksi ke database gagal: ' . mysqli_connect_error(), E_USER_ERROR); } ?&gt;</strong></pre><div><br>Seharusnya DB_SERVER , DB_USER , DB_PASSWORD, DB_DATABASE.<br>Itu Di Ganti Dengan Username , Password &amp; Nama Database Nya.<br><br>Contoh :&nbsp;</div><pre><strong>&lt;?php require_once DIR . '/db_config.php'; $conn = new mysqli(localhost, root, (password mysql agan), (nama database yang di buat)); if (mysqli_connect_errno()) { trigger_error('Koneksi ke database gagal: ' . mysqli_connect_error(), E_USER_ERROR); } ?&gt;</strong></pre>

avatar X451
@X451

41 Kontribusi 30 Poin

Dipost 3 tahun yang lalu

<pre>&lt;?php require_once DIR . '/db_config.php'; $conn = new mysqli(DB_SERVER, DB_USER, DB_PASSWORD, DB_DATABASE); if (mysqli_connect_errno()) { trigger_error('Koneksi ke database gagal: ' . mysqli_connect_error(), E_USER_ERROR); } ?&gt;</pre>

avatar X451
@X451

41 Kontribusi 30 Poin

Dipost 2 tahun yang lalu

Login untuk ikut Jawaban