Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > Error แบบนี้แก้อย่างไรครับ ผมก็ใช้ตัวอย่างตามบทเรียนนะครับ ช่วยดูให้ด้วยครับ (ตัดเฉพาะ code ที่ error มาให้ดูครับ) Warning: odbc_exec():



 

Error แบบนี้แก้อย่างไรครับ ผมก็ใช้ตัวอย่างตามบทเรียนนะครับ ช่วยดูให้ด้วยครับ (ตัดเฉพาะ code ที่ error มาให้ดูครับ) Warning: odbc_exec():

 



Topic : 008991

Guest




ผมก็ใช้ตัวอย่างตามบทเรียนนะครับ ช่วยดูให้ด้วยครับ (ตัดเฉพาะ code ที่ error มาให้ดูครับ)

Warning: odbc_exec(): SQL error: [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'ID='., SQL state 37000 in SQLExecDirect in d:\appserv\www\edit_customer_3.php on line 26
เอ็กซิคิวส์คำสั่งไม่ได้

ไฟล์ edit_customer_3.php
<?
$dsn_name = "data";
$username ="";
$password ="";
$connect= odbc_connect($dsn_name, $username, $password) or die("ติดต่อ DSN ไม่ได้");
$sql = "update Detail_ByCustomer set address='$address',province='$province' where ID=$ID";
$execute = odbc_exec($connect, $sql) or die ("เอ็กซิคิวส์คำสั่งไม่ได้");

$ID=odbc_result($execute,"ID");
$dep=odbc_result($execute,"dep");
$div=odbc_result($execute,"div");
$fname=odbc_result($execute,"fname");
$lname=odbc_result($execute,"lname");

odbc_close($connect);
header("Location: edit_customer_2.php");
?>


Tag : - - - -







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 6 ก.ค. 2549 10:18:23 By : chai View : 2056 Reply : 3
 

 

No. 1

Guest


เอา code ทั้งหมดมาให้ดูดีกว่า

<?
session_start();
session_register("login_name");
session_cache_expire(1);
if(empty($login_name))
{
header('location: login.php');
exit();
}
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
<title>Untitled Document</title>
</head>
<body>

<?
$dsn_name = "data";
$username ="";
$password ="";
$connect= odbc_connect($dsn_name, $username, $password) or die("ติดต่อ DSN ไม่ได้");
$sql = "update Detail_ByCustomer set address='$address',province='$province' where ID=$ID";
$execute = odbc_exec($connect, $sql) or die ("เอ็กซิคิวส์คำสั่งไม่ได้");

$ID=odbc_result($execute,"ID");
$dep=odbc_result($execute,"dep");
$div=odbc_result($execute,"div");
$fname=odbc_result($execute,"fname");
$lname=odbc_result($execute,"lname");
$code_pstn=odbc_result($execute,"code_pstn");
$name=odbc_result($execute,"name");
$business=odbc_result($execute,"business");
$address=odbc_result($execute,"address");
$province=odbc_result($execute,"province");
$tel=odbc_result($execute,"tel");
$fax=odbc_result($execute,"fax");
$contact_1=odbc_result($execute,"contact_1");
$contact_2=odbc_result($execute,"contact_2");
$contact_3=odbc_result($execute,"contact_3");
$position_1=odbc_result($execute,"position_1");
$position_2=odbc_result($execute,"position_2");
$position_3=odbc_result($execute,"position_3");
$contact_tel1=odbc_result($execute,"contact_tel1");
$contact_tel2=odbc_result($execute,"contact_tel2");
$contact_tel3=odbc_result($execute,"contact_tel3");
$remark=odbc_result($execute,"remark");

odbc_close($connect);
header("Location: edit_customer_2.php");
?>

</body>
</html>






Date : 6 ก.ค. 2549 10:23:45 By : chai
 


 

No. 2

Guest


เนื่องจาก $ID มีค่าเป็นว่างครับ
มันจึงได้เป็น

Where ID='

ให้แก้เป็น

$sql = "update Detail_ByCustomer set address='$address',province='$province' where ID='$ID' ";

Date : 6 ก.ค. 2549 10:35:11 By : เอก
 

 

No. 3

Guest


ขอบคุณ คุณเอก มากครับที่ช่วยตอบ
แต่พอเปลี่ยนแล้วขึ้นอย่างนี้แทนครับ

Warning: odbc_exec(): SQL error: [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression., SQL state 22005 in SQLExecDirect in d:\appserv\www\edit_customer_3.php on line 26
เอ็กซิคิวส์คำสั่งไม่ได้

ซึ่งในหน้าที่แสดงรายละเอียดที่ให้แก้ไขก็กำหนดเป็น where ID=$ID ก็ไม่เกิด error นะครับ
ตัวอย่าง Code ครับ

ไฟล์ edit_customer_2.php

<?
session_start();
session_register("login_name");
session_cache_expire(1);
if(empty($login_name))
{
header('location: login.php');
exit();
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- DW6 -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
<title>Corporate Solutions</title>
<link rel="stylesheet" href="styles/emx_nav_left.css" type="text/css">
<script type="text/javascript">
<!--
var time = 3000;
var numofitems = 7;

//menu constructor
function menu(allitems,thisitem,startstate){
callname= "gl"+thisitem;
divname="subglobal"+thisitem;
this.numberofmenuitems = 7;
this.caller = document.getElementById(callname);
this.thediv = document.getElementById(divname);
this.thediv.style.visibility = startstate;
}

//menu methods
function ehandler(event,theobj){
for (var i=1; i<= theobj.numberofmenuitems; i++){
var shutdiv =eval( "menuitem"+i+".thediv");
shutdiv.style.visibility="hidden";
}
theobj.thediv.style.visibility="visible";
}

function closesubnav(event){
if ((event.clientY <48)||(event.clientY > 107)){
for (var i=1; i<= numofitems; i++){
var shutdiv =eval('menuitem'+i+'.thediv');
shutdiv.style.visibility='hidden';
}
}
}
// -->
</script>
<style type="text/css">
<!--
.style4 {font-size: 12px; font-weight: bold; }
.style19 {font-size: 12px; font-weight: bold; color: #000000; }
.style20 {font-size: 10px; color: #000000; }
.style22 {font-size: 12px}
body {
background-image: url();
}
-->
</style>
</head>
<body onmousemove="closesubnav(event);">
<table width="756" border="1" cellspacing="0" cellpadding="0">
<tr>
<td width="746" bordercolor="#000000"><img src="image/logo_ttt1.jpg" width="237" height="63"> <img src="image/department.JPG" width="502" height="60" align="bottom"></td>
</tr>
</table>
<table width="755" border="1" cellspacing="0" cellpadding="0">
</table>
<p><a href="index.php"><img src="image/Menu_1.JPG" width="83" height="25" border="0"></a><a href="search_customer.php"><img src="image/Menu_2.JPG" width="83" height="25" border="0"></a><a href="detail_revenue.php"><img src="image/Menu_3.JPG" width="83" height="25" border="0"></a><a href="detail_pstn.php"><img src="image/Menu_4.JPG" width="83" height="25" border="0"></a><a href="detail_dcn.php"><img src="image/Menu_5.JPG" width="83" height="25" border="0"></a><img src="image/Menu_6.JPG" width="83" height="25"><a href="edit_customer_1.php"><img src="image/Menu_7.JPG" width="83" height="25" border="0"></a><a href="download.php"><img src="image/Menu_8.JPG" width="83" height="25" border="0"></a><a href="logout.php"><img src="image/Menu_9.JPG" width="83" height="25" border="0"></a></p>
<table width="752" border="1" cellspacing="0" cellpadding="0">
<tr bgcolor="#B8C9DD">
<td colspan="5" bgcolor="#EBEBEB">
<?
$dsn_name = "data";
$username ="";
$password ="";
$connect= odbc_connect($dsn_name, $username, $password) or die("ติดต่อ DSN ไม่ได้");
$sql = "select * from Detail_ByCustomer where ID=$ID";
$execute = odbc_exec($connect, $sql) or die ("เอ็กซิคิวส์คำสั่งไม่ได้");

$ID=odbc_result($execute,"ID");
$dep=odbc_result($execute,"dep");
$div=odbc_result($execute,"div");
$fname=odbc_result($execute,"fname");
$lname=odbc_result($execute,"lname");
$code_pstn=odbc_result($execute,"code_pstn");
$name=odbc_result($execute,"name");
$business=odbc_result($execute,"business");
$address=odbc_result($execute,"address");
$province=odbc_result($execute,"province");
$tel=odbc_result($execute,"tel");
$fax=odbc_result($execute,"fax");
$contact_1=odbc_result($execute,"contact_1");
$contact_2=odbc_result($execute,"contact_2");
$contact_3=odbc_result($execute,"contact_3");
$position_1=odbc_result($execute,"position_1");
$position_2=odbc_result($execute,"position_2");
$position_3=odbc_result($execute,"position_3");
$contact_tel1=odbc_result($execute,"contact_tel1");
$contact_tel2=odbc_result($execute,"contact_tel2");
$contact_tel3=odbc_result($execute,"contact_tel3");
$remark=odbc_result($execute,"remark");
?>
</td>
</tr>
<form name="form1" method="post" action="edit_customer_3.php">
<tr>
<td width="111" height="25" bgcolor="#EBEBEB"><div align="center"><span class="style4"> ชื่อบริษัท </span></div></td>
<td colspan="4" bgcolor="#EBEBEB"><span class="style22"><div style="margin-left: 10px"><? echo $name;?></td>
</tr>
<tr>
<td height="25" bgcolor="#EBEBEB"><div align="center"><span class="style4">ประเภทกิจการ</span></div></td>
<td colspan="4" bgcolor="#EBEBEB"><span class="style22"><div style="margin-left: 10px"><? echo $business;?></td>
</tr>
<tr>
<td height="25" bgcolor="#EBEBEB"><div align="center"><span class="style4">ที่อยู่สำนักงานใหญ่</span></div></td>
<td colspan="4" bgcolor="#EBEBEB"><input name="name" type="text" value="<?=$address;?>" size="85" width="500"></td>
</tr>
<tr>
<td height="25" bgcolor="#EBEBEB"><div align="center"><span class="style4">จังหวัด</span></div></td>
<td colspan="4" bgcolor="#EBEBEB"><input type="text" name="name" value="<?=$province;?>" size="20"></td>
</tr>
<tr>
<td height="25" bgcolor="#EBEBEB"><div align="center"><span class="style4">เบอร์โทรศัพท์</span></div></td>
<td colspan="4" bgcolor="#EBEBEB"><input type="text" name="name" value="<?=$tel;?>" size="20"></td>
</tr>
<tr>
<td height="25" bgcolor="#EBEBEB"><div align="center"><span class="style4">เบอร์แฟกซ์</span></div></td>
<td colspan="4" bgcolor="#EBEBEB"><input type="text" name="name" value="<?=$fax;?>" size="20"></td>
</tr>
<tr>
<td height="25" bgcolor="#EBEBEB"><div align="center"><span class="style4">ชื่อผู้ติดต่อ</span></div></td>
<td colspan="4" bgcolor="#EBEBEB">
<div align="left">
<span class="style22"><div style="margin-left: 3px">
<div align="left"><span class="style22"><strong>1.</strong></span> <input name="name" type="text" value="<?=$contact_1;?>" size="81">
</div>
</div>
<div align="center" class="style22"></div> <div align="center">
</div> <div align="center" class="style22"></div> <div align="center">
</div></td>
</tr>
<tr>
<td height="25" bgcolor="#EBEBEB">&nbsp;</td>
<td width="39" bgcolor="#EBEBEB"><div align="center"><span class="style22"><div class="style22" style="margin-left: 5px">
<div align="center"><strong>ตำแหน่ง</strong></div>
</div></td>
<td width="324" bgcolor="#EBEBEB"><input name="name" type="text" value="<?=$position_1;?>" size="43"></td>
<td width="34" bgcolor="#EBEBEB"><div align="center" class="style4">เบอร์</div></td>
<td width="232" bgcolor="#EBEBEB"><input name="name" type="text" value="<?=$contact_tel1;?>" size="22"></td>
</tr>
<tr>
<td height="25" bgcolor="#EBEBEB">&nbsp;</td>
<td colspan="4" bgcolor="#EBEBEB"><div align="center">
</div>
<div align="left">
<span class="style22"><div style="margin-left: 3px"><span class="style22"><strong>2.</strong></span>
<input name="name" type="text" value="<?=$contact_2;?>" size="81">
</div>
<div align="center">
</div></td>
</tr>
<tr>
<td height="25" bgcolor="#EBEBEB">&nbsp;</td>
<td bgcolor="#EBEBEB"><div align="center"><span class="style22"><div class="style22" style="margin-left: 5px">
<div align="center"><strong>ตำแหน่ง
</strong></div>
</div></td>
<td bgcolor="#EBEBEB"><div align="center" class="style22">
<div align="left">
<input name="name" type="text" value="<?=$position_2;?>" size="43">
</div>
</div></td>
<td bgcolor="#EBEBEB"><div align="center" class="style4">เบอร์</div></td>
<td bgcolor="#EBEBEB"><div align="center" class="style22"></div>
<div align="left">
<input name="name" type="text" value="<?=$contact_tel2;?>" size="22">
</div></td>
</tr>
<tr>
<td height="25" bgcolor="#EBEBEB">&nbsp;</td>
<td colspan="4" bgcolor="#EBEBEB"><div style="margin-left: 3px">
<span class="style22">
<div style="margin-left: 3px"><span class="style22"><strong>3.</strong></span>
<input name="name" type="text" value="<?=$contact_3;?>" size="80">
</div>
<div align="left"></div></td>
</tr>
<tr>
<td height="25" bgcolor="#EBEBEB">&nbsp;</td>
<td bgcolor="#EBEBEB"><div align="center"><span class="style22"><div style="margin-left: 5px">
<div align="center" class="style4">ตำแหน่ง </div>
</div></td>
<td bgcolor="#EBEBEB"><input name="name" type="text" value="<?=$position_3;?>" size="43"></td>
<td bgcolor="#EBEBEB"><div align="center" class="style4">เบอร์</div></td>
<td bgcolor="#EBEBEB"><input name="name" type="text" value="<?=$contact_tel3;?>" size="22"></td>
</tr>
<tr>
<td height="25" bgcolor="#EBEBEB"><div align="center"><span class="style4">หมายเหตุ</span></div></td>
<td colspan="4" bgcolor="#EBEBEB"><input name="name" type="text" value="<?=$remark;?>" size="84"></td>
</tr>
<tr>
<td height="25" bgcolor="#EBEBEB"><div align="center"><span class="style4">หน่วยงานรับผิดชอบ</span></div></td>
<td colspan="4" bgcolor="#EBEBEB"><span class="style22"><div style="margin-left: 10px"><? echo $div;?></td>
</tr>
<tr>
<td height="25" bgcolor="#EBEBEB"><div align="center" class="style4">ผู้รับผิดชอบ</div></td>
<td colspan="4" bgcolor="#EBEBEB"><span class="style22"><div style="margin-left: 10px"><? echo $fname;?> <? echo $lname;?></td>
</tr>
<td colspan="5" bgcolor="#EBEBEB">
<input type="submit" name="submit" value="update" >
<input type="hidden" name="customer" value="<?=$ID;?>">
</form>
<?
odbc_close($connect);
?>
</table>

</body>
</html>

รบกวนคุณเอก หรือผู้รู้ทุกท่าน ช่วยดูให้อีกรอบครับ ขอบคุณมากครับ

Date : 6 ก.ค. 2549 11:26:47 By : chai
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : Error แบบนี้แก้อย่างไรครับ ผมก็ใช้ตัวอย่างตามบทเรียนนะครับ ช่วยดูให้ด้วยครับ (ตัดเฉพาะ code ที่ error มาให้ดูครับ) Warning: odbc_exec():
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 00
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่