尝试编译它时出现此错误
解析错误:语法错误,出现意外的“ if”(T_IF) D:\ xampp \ htdocs \ ProyeKoperasi \ views \ tambah.php在第4行
<?php
include 'Koneksi/koneksi.php';
if ($_SERVER['REQUEST_METHOD'] == "POST") {//here is line number 4
$id_koperasi = $_POST['id'];
$nama_koperasi = $_POST['nama'];
$alamat = $_POST['alamat'];
$telp = $_POST['telp'];
$hp = $_POST['hp'];
$nama_cp = $_POST['kontak'];
$email = $_POST['email'];
$nama_cp = $_POST['kontak'];
$day1 = strtotime($_POST["tgl"]);
$day1 = date('Y-m-d H:i:s', $day1);
$ket_fu = $_POST['Ket'];
$pilih_ket = "";
foreach ($ket_fu as $Ket)
{
$pilih_ket .= $Ket . ", ";
}
$pilih_ket = substr($pilih_ket, 0, -2);
$hasil_pembahasan = $_POST['Hasil'];
$query = "INSERT INTO t_koperasi VALUES (
'$id_koperasi',
'$nama_koperasi',
'$alamat',
'$telp',
'$hp',
'$nama_cp',
'$day1',
'$pilih_ket',
'$hasil_pembahasan')"
;
if (mysqli_query($con,$query)) {
header("location:index.php");
}else {
echo '<script type ="text/javascript">alert("Data gagal ditambahkan");</script>;';
}
}
include 'views/v_tambah.php';
?>
答案 0 :(得分:-1)
尝试一下
if (isset($_SERVER['REQUEST_METHOD']) && ($_SERVER['REQUEST_METHOD']== "POST")) { //Line 4
如果这不起作用,则require中的文件存在代码问题,或者您可能未添加所有代码,因为我没有发现sintax问题