Postingan lainnya
Parse error: syntax error, unexpected token "if"
Parse error: syntax error, unexpected token "if" in C:\xampp\htdocs\karajanfarma\prosesinsert_obat.php on line 16
<?php
include('koneksi.php');
$id_obat = $_POST['id_obat'];
$kode_obat = $_POST['kode_obat'];
$kode_obat = $_POST['kode_obat'];
$kategori_obat = $_POST['kategori_obat'];
$jenis_obat = $_POST['jenis_obat'];
$harga_beli = $_POST['harga_beli'];
$harga_jual = $_POST['harga_jual'];
$jumlah_obat = $_POST['jumlah_obat'];
$tanggal_masuk = $_POST['tgl_masuk'];
$expired = $_POST['expired'];
$gambar = $_FILES['gambar']['name']
if($gambar != ""){
$ekstensi_diperbolehkan = array('png', 'jpg');
$x = explode('', $gambar);
$ekstensi = strtok(end, $x));
$file_tmp = $$_FILES['gambar']['tmp_name'];
$angka_acak = rand(1, 999);
$gambar_baru = $angka_acak. '-' .$gambar;
if(in_array($ekstensi, $ekstensi_diperbolehkan) === true){
move_uploaded_file($file_tmp, 'img/'.$gambar_baru);
}
}
mysql_query($koneksi, "INSERT INTO obat (id_obat, kode_obat, nama_obat, kategori_obat, jenis_obat, harga_beli, harga_jual, jumlah_obat, tgl_masuk, expired, gambar) VALUES ('$id_obat', '$kode_obat', '$nama_obat', '$kategori_obat', '$jenis_obat', '$harga_beli', '$harga_jual', '$jumlah_obat', '$tgl_masuk', '$expired', '$gambar')");
$result = mysqli_query($koneksi, $query);
if(!result){
die("Query Error : ".mysqli_error($koneksi)."-".mysqli_error($koneksi));
} else {
echo "Data gagal dimasukkan ke Database karena " . mysqli_error($koneksi);
}
header("location:obat.php");
?>
3 Jawaban:
<div>Ada yg kurang itu mas di line 14</div><div><br></div>
<div>Kurang titik koma di akhir line 14</div>
Selamat Siang kaka. saya juga mempunyai masalah seperti ini kak: MOHON BERIKAN SOLUSINYA DONG. Parse error: syntax error, unexpected token "if" in C:\xampp\htdocs\biometricattendancev2\connectDB.php on line 10
SCRIPTNYA BERIKUT: <?php /* Database connection settings */ $servername = "localhost"; $username = "root"; //put your phpmyadmin username.(default is "root") $password = ""; //if your phpmyadmin has a password put it here.(default is "root") $dbname = "biometricattendace";
$conn = mysql_connect($mysql_hostname , $mysql_username, $mysql_password)
if ($conn->connect_error) {
die("Database Connection failed: " . $conn->connect_error);
}
?>