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 '' at line 1
โค้ด
โค้ด: เลือกทั้งหมด
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
.style1 {color: #FFFFFF}
-->
</style>
</head>
<body>
<? include("config.php");
$sql = "select * from member where ID = $id_member";
$result = mysql_query($sql) or die(mysql_error());
$row = mysql_num_rows($result);
if($row == 0)
{
echo "ไม่พบข้อมูล";
}
else
{
$fetch_member = mysql_fetch_array($result);
$user_id = $fetch_member['user_id'];
$ID_card = $fetch_member['ID_card'];
$Name = $fetch_member['Name'];
$Address = $fetch_member['Address'];
$Tel = $fetch_member['Tel'];
$email = $fetch_member['email'];
$sql_user = "select * from user where id_user = $user_id";
echo "sql_user : " . " " . $sql_user . "<br>";
$result = mysql_query($sql_user);
$row = mysql_num_rows($result);
if($row == 0)
{
echo"ไม่พบข้อมูลในตาราง user";
}
else
{
$fetch_user = mysql_fetch_array($result);
$user_name = $fetch_user['user_name'];
$password = $fetch_user['password'];
}
}
?>
<form name="frmMain" action="edit_success.php" method="post" target="iframe_target">
<iframe id="iframe_target" name="iframe_target" src="#" style="width:0;height:0;border:0px solid #fff;"></iframe>
<script language="javascript">
function showResult(result)
{
alert(result);
if(result==1)
{
document.getElementById("divResult").innerHTML="<font color = red>กรุณาใส่ username ด้วย!!</font><br>";
}
else if(result==2)
{
document.getElementById("divResult").innerHTML="<font color = red>username นี้ไม่สามารถใช้ได้ มีคนใช้แล้ว</font><br>";
}
else if(result==3)
{
document.getElementById("divResult").innerHTML="<font color = red>กรุณาใส่รหัสผ่านด้วย</font><br>";
}
else if(result==4)
{
document.getElementById("divResult").innerHTML="<font color = red>กรุณาใส่รหัสผ่านทั้งสองครั้งให้ตรงกันด้วย</font><br>";
}
else if(result==5)
{
document.getElementById("divResult").innerHTML="<font color = red>กรุณาใส่หมายเลขประจำตัวประชาชน</font><br>";
}
else if(result==6)
{
document.getElementById("divResult").innerHTML="<font color = red>กรุณาใส่ชื่อ-นามสกุล</font><br>";
}
else if(result==7)
{
document.getElementById("divResult").innerHTML="<font color = red>กรุณาใส่หมายเลขโทรศัพท์</font><br>";
}
else if(result==8)
{
document.getElementById("divResult").innerHTML="<font color = red>กรุณาใส่ที่อยู่</font><br>";
}
else if(result==9)
{
document.getElementById("divResult").innerHTML="<font color = red>กรุณาใส่ E-mail</font><br>";
}
else
{
var url = "http://localhost/bit2255/index.php";
window.location = url;
}
}
</script>
<div id="divResult"></div>
<table width="432" border="1">
<tr>
<th colspan="2" bordercolor="#FF0000" bgcolor="#000000" scope="row"><span class="style1">สมัครสมาชิก</span></th>
</tr>
<tr>
<th bordercolor="#FF0000" bgcolor="#000000" scope="row"><div align="right"><span class="style1">User name :</span></div></th>
<td><input type="text" value="<? echo $user_name; ?>" name="user_name" />
<input type="hidden" name="old_username" value="<? echo $user_name; ?>" />
</td>
</tr>
<tr>
<th bordercolor="#FF0000" bgcolor="#000000" scope="row"><div align="right"><span class="style1">Password :</span></div></th>
<td><input type="password" value="<? echo $password; ?>" name="password" /><br />
<input type="hidden" name="old_password" value="<? echo $password; ?>" />
</td>
</tr>
<tr>
<th bordercolor="#FF0000" bgcolor="#000000" scope="row"><div align="right"><span class="style1">Confirm password :</span></div></th>
<td><input type="password" name="confirm_password" /></td>
</tr>
<tr>
<th width="154" bordercolor="#FF0000" bgcolor="#000000" scope="row"><div align="right"><span class="style1">รหัสประจำตัว :</span></div></th>
<td width="262">
<input type="text" value="<? echo $ID_card; ?>" name="ID_card" /> </td>
</tr>
<tr>
<th bordercolor="#FF0000" bgcolor="#000000" scope="row"><div align="right"><span class="style1">ชื่อ : </span></div></th>
<td><input type="text" value="<? echo $Name; ?>" name="Name" /></td>
</tr>
<tr>
<th bordercolor="#FF0000" bgcolor="#000000" scope="row"><div align="right"><span class="style1">ที่อยู่ : </span></div></th>
<td>
<input type="text" value="<? echo $Address; ?>" name="Address" /> </td>
</tr>
<tr>
<th bordercolor="#FF0000" bgcolor="#000000" scope="row"><div align="right"><span class="style1">เบอร์โทร : </span></div></th>
<td>
<input type="text" value="<? echo $Tel; ?>" name="Tel" /> </td>
</tr>
<tr>
<th bordercolor="#FF0000" bgcolor="#000000" scope="row"><div align="right"><span class="style1">E-mail :</span></div></th>
<td><input type="text" value="<? echo $email; ?>" name="email" /></td>
</tr>
<tr>
<th colspan="2" scope="row"><input type="submit" name="register" value="แก้ไข" />
<input type="button" name="reset" value="ยกเลิก" /> </th>
<input type="hidden" name="id_member" value="<? echo $id_member; ?>" />
<input type="hidden" name="id_user" value="<? echo $user_id; ?>" />
</tr>
</table>
</form>
</body>
</html>