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 > รบกวนช่วยดู Code ให้ด้วยครับ ว่าผิดตรงไหน เนื่องจากหลังจาก UPDATE แล้วจะฟ้อง ERROR ดังรูปครับ



 

รบกวนช่วยดู Code ให้ด้วยครับ ว่าผิดตรงไหน เนื่องจากหลังจาก UPDATE แล้วจะฟ้อง ERROR ดังรูปครับ

 



Topic : 086631



โพสกระทู้ ( 150 )
บทความ ( 0 )



สถานะออฟไลน์




Error Update

CODE ที่ใช้ครับ

Code (PHP)
<?php 
session_start();   
if($_SESSION['user_id'] == "")   {       
 header("location:index.php");    }   
if($_SESSION['user_status'] != "esc")   
{        
echo "This page for User only!";      
exit();   }      
mysql_connect("localhost","root","root");
   
mysql_select_db("parttime");
mysql_query("SET NAMES UTF8");
   
$strSQL = "SELECT * FROM user WHERE user_id = '".$_SESSION['user_id']."' ";
    
$objQuery = mysql_query($strSQL);
    
$objResult = mysql_fetch_array($objQuery);
?>
<?php require_once('Connections/parttime.php'); ?>

<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
$insertstartDate  = date("Y-m-d",strtotime($startdate));
$insertendDate  = date("Y-m-d",strtotime($enddate));

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "editdate")) {
  $updateSQL = sprintf("UPDATE history SET dept=%s, startdate=%s, enddate=%s WHERE id=%s",
                       GetSQLValueString($_POST['dept'], "text"),
                       GetSQLValueString($insertstartDate, "date"),
                       GetSQLValueString($insertendDate, "date"),
                       GetSQLValueString($_POST['id'], "int"));

  mysql_select_db($database_parttime, $parttime);
  $Result1 = mysql_query($updateSQL, $parttime) or die(mysql_error());

  $updateGoTo = "detail.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $updateGoTo));
}


$colname_editdate = "1";
if (isset($_GET['historyid'])) {
  $colname_editdate = (get_magic_quotes_gpc()) ? $_GET['historyid'] : addslashes($_GET['historyid']);
}
mysql_select_db($database_parttime, $parttime);
mysql_query ("SET NAMES UTF8");
$query_editdate = sprintf("SELECT * FROM history WHERE id = %s", $colname_editdate);
$editdate = mysql_query($query_editdate, $parttime) or die(mysql_error());
$row_editdate = mysql_fetch_assoc($editdate);
$totalRows_editdate = mysql_num_rows($editdate);

?>
<?php
mysql_select_db($database_parttime, $parttime);
$query_name = "SELECT parttime.name, parttime.surname FROM history LEFT JOIN parttime ON history.pt_id = parttime.id WHERE history.pt_id='".$row_editdate['pt_id']."'";
$name = mysql_query($query_name, $parttime) or die(mysql_error());
$row_name = mysql_fetch_assoc($name);
$totalRows_name = mysql_num_rows($name);


mysql_select_db($database_parttime, $parttime);
$query_edit ="SELECT *,DATE_FORMAT(startdate,'%d %b %Y') AS startdate  ,DATE_FORMAT(enddate,'%d %b %Y') AS enddate FROM history WHERE id = '".$row_editdate['id']."'";
$edit = mysql_query($query_edit, $parttime) or die(mysql_error());
$row_edit = mysql_fetch_assoc($edit);
$totalRows_edit = mysql_num_rows($edit);

?>
<!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=utf-8">
<title>edit date</title>
<style type="text/css">
<!--
.style1 {font-weight: bold}
.style3 {color: #0000FF}
-->
</style>
</head>
<table width="100%"  border="0" cellpadding="0" cellspacing="0">
  <tr bgcolor="#FF0000">
    <th height="41" scope="col">แก้ไขวันที่ทำงาน<span class="style5">ให้กับพนักงาน</span></th>
  </tr>
  <tr bgcolor="#FF0000">
    <th height="41" bgcolor="#FFFFFF" scope="col">&nbsp;	  </th>
  </tr>
</table>

  <form action="<?php echo $editFormAction; ?>" method="POST" name="editdate" id="editdate" onSubmit="MM_validateForm('location','','R','dept','','R','startdate','','R');return document.MM_returnValue">
    <table width="90%" height="202"  border="0" align="center" cellpadding="0" cellspacing="0">
      <tr valign="middle" bgcolor="#FF0000">
        <th height="30" colspan="5" scope="col"><div align="center"></div>          
          <div align="center" class="style5"></div>          <div align="center"></div>          <div align="center"></div></th>
      </tr>
      <tr bgcolor="#CCCCCC">
        <th height="32" scope="col"><span class="style3">
		
		</span></th>
        <th align="left" scope="col">ชื่อ</th>
        <th colspan="3" align="left" scope="col"><?php echo $row_name['name']; ?> </th>
      </tr>
      <tr bgcolor="#CCCCCC">
        <th height="32" scope="col">&nbsp;</th>
        <th align="left" scope="col">นามสกุล</th>
        <th colspan="3" align="left" scope="col"><?php echo $row_name['surname']; ?></th>
      </tr>
      <tr bgcolor="#CCCCCC">
        <th width="11%" height="32" scope="col">&nbsp;</th>
        <th width="17%" align="left" scope="col"><span class="style19 style1 style4">สาขา</span></th>
	
        <th colspan="3" align="left" scope="col"><?php echo $row_edit['location']; ?> </th>
      </tr>
      <tr bgcolor="#CCCCCC">
        <td height="33">&nbsp;</td>
        <td><strong>ตำแหน่งงาน</strong></td>
  
        <td width="33%"><input name="dept" type="text" id="dept" value="<?php echo $row_edit['dept']; ?>" size="30" maxlength="30" ></td>
        <td colspan="2"><input type="hidden" name="user_id" id="user_id" value=<?=$objResult["user_id"];?>></td>
      </tr>
      <tr bgcolor="#CCCCCC">
        <td height="33">&nbsp;</td>
        <td><span class="style19 style1 style4"><strong>จากวันที่</strong></span></td>
        <td>
	 <link rel="stylesheet" type="text/css" href="css/black-tie/jquery-ui-1.9.1.custom.min.css">
	<script src="css/js/jquery-1.8.2.js"></script>
	<script src="css/js/jquery-ui-1.9.1.custom.js"></script>
	<script src="development-bundle/ui/jquery.ui.datepicker.js"></script>

	<script>
	$(function() {
		$( "#startdate" ).datepicker({
			changeMonth: true,
			changeYear: true,
			 dateFormat: 'dd M yy'
		});
	});


	</script>
<style type="text/css">
.ui-datepicker{
	width:180px;
	font-family:tahoma;
	font-size:11px;
	text-align:center;
}
</style>
		<input name="startdate" type="text" id="startdate" value="<?php echo $row_edit['startdate']; ?>">
		</td>
        <td colspan="2"><input type="text" name="id" id="id" value=<?php echo $row_edit['id']; ?>>
      
      </tr>
      <tr bgcolor="#CCCCCC">
        <td height="34">&nbsp;</td>
        <td><span class="style19 style1 style4"><strong>ถึงวันที่</strong></span></td>
		 <td>
	 <link rel="stylesheet" type="text/css" href="css/black-tie/jquery-ui-1.9.1.custom.min.css">
	<script src="css/js/jquery-1.8.2.js"></script>
	<script src="css/js/jquery-ui-1.9.1.custom.js"></script>
	<script src="development-bundle/ui/jquery.ui.datepicker.js"></script>

	<script>
	$(function() {
		$( "#enddate" ).datepicker({
			changeMonth: true,
			changeYear: true,
			 dateFormat: 'dd M yy'
		});
	});


	</script>
<style type="text/css">
.ui-datepicker{
	width:180px;
	font-family:tahoma;
	font-size:11px;
	text-align:center;
}
</style>
       <input name="enddate" type="text" id="enddate" value="<?php echo $row_edit['enddate']; ?>"></td>
        <td colspan="2">&nbsp;</td>
      </tr>
      <tr bgcolor="#CCCCCC">
        <td colspan="2">&nbsp;</td>
        <td><input type="submit" name="submit" value="ยืนยันการบันทึก"></td>
        <td width="28%" colspan="2"><input type=button name=type value='  ยกเลิก  ' onClick="setVisibility('show_demo', '')";></td>
      </tr>
      <tr bgcolor="#CCCCCC">
        <td colspan="2"><input name="hiddenField" type="hidden" value="<?php echo $row_name['id']; ?>"></td>
        <td>&nbsp;</td>
        <td colspan="2">&nbsp;</td>
      </tr>
    </table>
    
    <input type="hidden" name="MM_update" value="editdate">  </form>


</body>
</html>
<?php
mysql_free_result($name);

mysql_free_result($edit);

mysql_free_result($editdate);
?>




Tag : PHP, JavaScript, jQuery







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2012-11-13 09:45:50 By : sranuwat View : 942 Reply : 5
 

 

No. 1



โพสกระทู้ ( 3,155 )
บทความ ( 0 )

สมาชิกที่ใส่เสื้อไทยครีเอท Hall of Fame 2012

สถานะออฟไลน์


ใช้โปรแกรมอะไรเขียนโค้ดครับ
ถ้าเป็น edit plus ตอนเซฟไฟล์ต้องเลือกเป็น UTF8
ถ้าเป็น notepad++ ต้องเป็น utf8 - without BOM
หลังจากนั้นให้ลบ <?php ในบรรทัดแรก ด้วยการกดปุ่ม "Backspace" เคาะซ้ำๆไปหลายๆที แล้วพิมพ์ <?php เข้าไปใหม่






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-11-13 16:11:13 By : sakuraei
 


 

No. 2



โพสกระทู้ ( 150 )
บทความ ( 0 )



สถานะออฟไลน์


ผมใช้ DREAMWAVER MX2004 ครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-11-13 16:24:14 By : sranuwat
 

 

No. 3



โพสกระทู้ ( 3,155 )
บทความ ( 0 )

สมาชิกที่ใส่เสื้อไทยครีเอท Hall of Fame 2012

สถานะออฟไลน์


ลองหา ดาวน์โหลดnotepad++ มาใช้แก้ไขโค้ดดูน่ะครับ แล้วทำตามที่ผมบอก
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-11-13 16:31:42 By : sakuraei
 


 

No. 4



โพสกระทู้ ( 150 )
บทความ ( 0 )



สถานะออฟไลน์


ครับ ได้ครับ ขอบคุณมากครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-11-13 16:32:51 By : sranuwat
 


 

No. 5



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

ใช้ Edit Plus ก็ได้ครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-11-14 09:14:20 By : mr.win
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : รบกวนช่วยดู Code ให้ด้วยครับ ว่าผิดตรงไหน เนื่องจากหลังจาก UPDATE แล้วจะฟ้อง ERROR ดังรูปครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ 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 01
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 อัตราราคา คลิกที่นี่