I try to pass some data to mysql but i didnt work.did i miss something. i already check my database name and table.
<?php
$dbServername = "localhost";
$dbUsername = "root";
$dbPassword = "";
$dbName = "pelanggan";
$conn = mysqli_connect($dbServername, $dbUsername, $dbPassword, $dbName);
if (!$conn) {
die('error connecting to database');
}
It keeps giving me the "connection error" message:
<?php
include_once 'includes/dbh.inc.php';
?>
<html>
<body>
<form action='form.php' method='POST'>
NAMA: <br> <input type='text' name='nama'><br>
NO TELP : <br> <input type='text' name='telp'><br>
PAKET DATA: <br> <input type='text' name='paket'><br>
<button value='submit' name='submit'>submit</button>
</form>
</body>
</html>
<?php
if (isset($_POST['nama']) && isset ($_POST['telp']) && isset($_POST['paket'])) {
$nama = $_POST['nama'];
$telp = $_POST['telp'];
$paket = $_POST['paket'];
if (empty ($nama) || empty ($telp) || empty ($paket)) {
echo '*FIELDS MUST BE FILLED';
} else {
$sqlinsert = "INSERT INTO daftarpelanggan (nama,telp,paket) VALUES ('$nama','$telp','$paket')";
if (!mysqli_query($conn, $sqlinsert)) {
die ('connection error');
} else {
echo '1 record has been added successfully';
}
}
}
?>
"Fatal error: Uncaught exception 'mysqli_sql_exception' with message 'Table 'daftarpelanggan' is read only
die ('connection error' . mysqli_error($conn));and tell what you get.ini_set('display_errors', 1); ini_set('log_errors',1); error_reporting(E_ALL); mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);to the top of your script. This will force anymysqli_errors to generate an Exception that you can see on the browser and other errors will also be visible on your browser.