มัน error อารัยผมไม่เข้าใจครับ ช่วยทีครับ

สำหรับผู้ที่ เริ่มต้น Programming - PHP มีอะไร แนะนำ หรือข้อสงสัยต้องบอร์ด นี้ คนที่มีความรู้ แบ่งปันคนอื่นบ้างนะ ปัญหาการเขียนโปรแกรม แบบ OOP Session Cookies php network

Moderator: mindphp, ผู้ดูแลกระดาน

ปารเมศ

มัน error อารัยผมไม่เข้าใจครับ ช่วยทีครับ

โพสต์ที่ยังไม่ได้อ่าน โดย ปารเมศ »

มันขึ้น

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">&#3626;&#3617;&#3633;&#3588;&#3619;&#3626;&#3617;&#3634;&#3594;&#3636;&#3585;</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">รหัส&#3611;&#3619;&#3632;&#3592;ำตัว :</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">&#3648;&#3610;&#3629;&#3619;&#3660;&#3650;&#3607;&#3619; : </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>
ภาพประจำตัวสมาชิก
mindphp
ผู้ดูแลระบบ MindPHP
ผู้ดูแลระบบ MindPHP
โพสต์: 41245
ลงทะเบียนเมื่อ: 22/09/2008 6:18 pm
ติดต่อ:

Re: มัน error อารัยผมไม่เข้าใจครับ ช่วยทีครับ

โพสต์ที่ยังไม่ได้อ่าน โดย mindphp »

ไม่เกี่ยวกับ bit ครับ
syntax error คือเขียนเป็นรูปแบบไวยากรณ์ ภาษา sql ครับ
ติดตาม VDO: http://www.youtube.com/c/MindphpVideoman
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
ปารเมศ

Re: มัน error อารัยผมไม่เข้าใจครับ ช่วยทีครับ

โพสต์ที่ยังไม่ได้อ่าน โดย ปารเมศ »

แล้วต้องแก้ไขยังไงครับ พอดีเพิ่งศึกษาครับ
HurricaneCyber
PHP Full Member
PHP Full Member
โพสต์: 33
ลงทะเบียนเมื่อ: 27/08/2012 1:22 pm

Re: มัน error อารัยผมไม่เข้าใจครับ ช่วยทีครับ

โพสต์ที่ยังไม่ได้อ่าน โดย HurricaneCyber »

ลอง echo คำสั่ง sql มาเช็คดูครับ หรือ ไม่ก็ใส่ or die(mysql_error()); หลัง mysql_query() ดู
ตอบกลับโพส
  • Similar Topics
    ตอบกลับ
    แสดง
    โพสต์ล่าสุด

ผู้ใช้งานขณะนี้

สมาชิกกำลังดูบอร์ดนี้: ไม่มีสมาชิกใหม่ และบุคลทั่วไป 129