我有一个简单的MySQL UPDATE语句,从表id_pt
中选择tbl_pt
并且更新无法正常显示错误You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE id_pt = '1'' at line 6
更新aksi_identitas.php
<?php
session_start();
if (empty($_SESSION['namauser']) AND empty($_SESSION['passuser'])){
echo "<link href='style.css' rel='stylesheet' type='text/css'>
<center>Untuk mengakses modul, Anda harus login <br>";
echo "<a href=../../index.php><b>LOGIN</b></a></center>";
}
else{
include "../../../config/koneksi.php";
$module=$_GET[module];
$act=$_GET[act];
// Update identitas
if ($module=='identitas' AND $act=='update'){
$c = mysql_query("UPDATE tbl_pt SET nama_pt = '$_POST[nama_pt]',
alamat_pt = '$_POST[alamat_pt]',
phone_pt = '$_POST[phone_pt]',
email_pt = '$_POST[email_pt]',
fax_pt = '$_POST[fax_pt]',
WHERE id_pt = '$_POST[id]'");
if ($c) {
header('location:../../media.php?module='.$module);
}else{
echo "Gagal ".mysql_error();
}
}
}
?>
identitas.php
<?php
$aksi="modul/mod_identitas/aksi_identitas.php";
switch($_GET[act]){
// Tampil identitas
default:
$sql = mysql_query("SELECT * FROM tbl_pt LIMIT 1");
$r = mysql_fetch_array($sql);
echo "
<div id='main-content'>
<div class='container_12'>
<div class='grid_12'>
</div>
<div class='grid_12'>
<div class='block-border'>
<div class='block-header'>
<h1>IDENTITAS PERUSAHAAN</h1>
<span></span>
</div>
<div class='block-content'>
<form method=POST enctype='multipart/form-data' action=$aksi?module=identitas&act=update>
<input type=hidden name=id value=$r[id_pt]>
<p class=inline-small-label>
<label for=field4>Nama Perusahaan</label>
<input type=text name='nama_pt' size=50 value='$r[nama_pt]'>
</p>
<p class=inline-small-label>
<label for=field4>Alamat Perusahaan</label>
<input type=text name='alamat_pt' size=50 value='$r[alamat_pt]'>
</p>
<p class=inline-small-label>
<label for=field4>Telepon Perusahaan</label>
<input type=text name='phone_pt' size=50 value='$r[phone_pt]'>
</p>
<p class=inline-small-label>
<label for=field4>Email Perusahaan</label>
<input type=text name='email_pt' size=50 value='$r[email_pt]'>
</p>
<p class=inline-small-label>
<label for=field4>Fax Perusahaan</label>
<input type=text name='fax_pt' size=50 value='$r[fax_pt]'>
</p>";
echo "<div class=block-actions>
<ul class=actions-right>
<li>
<a class='button red' id=reset-validate-form href='?module=identitas'>Batal</a>
</li> </ul>
<ul class=actions-left>
<li>
<input type='submit' name='upload' class='button' value=' Simpan '>
</form>";
break;
}
?>
</div>
</div>
</div>
<div class='clear height-fix'></div>
</div></div>
任何帮助将不胜感激,谢谢!
答案 0 :(得分:0)
在WHERE