syntax ?> untuk end of file apa ya di php

<?php

require_once 'config.php';

$dbConn = mysqli_connect ($dbHost, $dbUser, $dbPass) or die ('MySQL connect failed. ' . mysqli_error());

mysqli_select_db($dbConn, $dbName) or die('Cannot select database. ' . mysqli_error());

function dbQuery($sql)

{

    $sql = ['SELECT uid, uname, utype FROM tbl_users '];

    $result = mysqli_query ("SELECT * from tbl_users where username='$dbUser' and password='$dbPass') or die(mysqli_connect_error());

    return $result;

}

function dbAffectedRows()

{

    global $dbConn;

    return mysqli_affected_rows($dbConn);

}

function dbFetchArray($result, $resultType = MYSQLi_NUM) {

    return mysqli_fetch_array($result, $resultType);

}

function dbFetchAssoc($result)

{

    return mysqli_fetch_assoc($result);

}

function dbFetchRow($result)

{

    return mysqli_fetch_row($result);

}

function dbFreeResult($result)

{

    return mysqli_free_result($result);

}

function dbNumRows($result)

{

    return mysqli_num_rows($result);

}

function dbSelect($dbName)

{

    return mysqli_select_db($dbName);

}

function dbInsertId()

{

    return mysqli_insert_id();

}

?>

berikut error nya:

Parse error: syntax error, unexpected end of file in B:\xampp baru\htdocs\asset_management\library\database.php on line 55

mohon bantuan nya, apa yang harus ditambahkan pada syntax ?> agar bisa tutup?

avatar marissafiddarayni
@marissafiddarayni

4 Kontribusi 3 Poin

Diperbarui 3 tahun yang lalu

Tanggapan

coba kirim potongan kode-nya sebagai "script", jangan sebagai teks biasa, untuk membaca potongna kodenya agak susah

1 Jawaban:

<div>Ini coba saya betulkan dan rapihkan:</div><pre>&lt;?php require_once 'config.php'; $dbConn = mysqli_connect ($dbHost, $dbUser, $dbPass) or die ('MySQL connect failed. ' . mysqli_error()); mysqli_select_db($dbConn, $dbName) or die('Cannot select database. ' . mysqli_error()); function dbQuery($sql){ $sql = ['SELECT uid, uname, utype FROM tbl_users ']; $result = mysqli_query("SELECT * from tbl_users where username='$dbUser' and password='$dbPass'") or die(mysqli_connect_error()); return $result; } function dbAffectedRows(){ global $dbConn; return mysqli_affected_rows($dbConn); } function dbFetchArray($result, $resultType = MYSQLi_NUM) { return mysqli_fetch_array($result, $resultType); } function dbFetchAssoc($result){ return mysqli_fetch_assoc($result); } function dbFetchRow($result) { return mysqli_fetch_row($result); } function dbFreeResult($result){ return mysqli_free_result($result); } function dbNumRows($result){ return mysqli_num_rows($result); } function dbSelect($dbName){ return mysqli_select_db($dbName); } function dbInsertId(){ return mysqli_insert_id(); } ?&gt;</pre><div><br>Penjelasan:<br>Yang jadi masalah adalah di variable $result.</div><pre>$result = mysqli_query ("SELECT * from tbl_users where username='$dbUser' and password='$dbPass') or die(mysqli_connect_error());</pre><div><br>Di function mysqli_query() anda kurang teliti dengan menambahkan tanda petik ganda, yang benar adalah seperti ini:</div><pre>$result = mysqli_query("SELECT * from tbl_users where username='$dbUser' and password='$dbPass'") or die(mysqli_connect_error());</pre><div><br>Semoga cepat paham dan membantu.</div>

avatar syahid246
@syahid246

70 Kontribusi 160 Poin

Dipost 3 tahun yang lalu

Login untuk ikut Jawaban