|  | 
	                
  
    | 
	 
        ช่วยตรวจสอบโค้ด php ให้หน่อยคะ ว่ามีอะไรตรงไหนผิดบ้าง หนูแก้ไม่ได้คะ     |  
    |  |  
 
	
		|  |  |  |  |  
		|  |  | 
          
            | โค้ดหน้าที่ผิดคะ 
 
 Code (PHP)
 
 <?
        session_start();
		ob_start();
		
				
		// $status = $_SESSION["STATUS"];
		$cde  = $_SESSION["CTL_CDE"];
		$nameOrg = $_SESSION["CTL_NME"];
	//   $cde = $_REQUEST["$cde"];
	 //  $nameOrg = $_REQUEST["$nameOrg"];
	 
	 
	   	$nme = $_REQUEST["nme"];
		$surnme = $_REQUEST["surnme"];
		$tel = $_REQUEST["tel"];
		$email = $_REQUEST["e_mail"];
		$level_nme = $_REQUEST["level_nme"];
		$pos_nme = $_REQUEST["pos_nme"];
	//     	  echo "cde".$cde."<br>";
	//	 	  echo "name".$nameOrg."<br>";
		//	  echo "name".$nme."<br>";
	//		  echo "surname".$surnme."<br>";
	//		  echo "tel".$tel."<br>";
	//		  echo "e_mail".$e_mail."<br>";
// เพิ่มข้อมูลผู้แจ้ง
/*if($id == "" || $pos_id == "" || $prefix_name =="" || $nme=="" || $surnme=="" || $cde =="" || $id_card ==""  || $per_typ=="")
{
    $err = "กรุณากรอกข้อมูลให้ครบครับ";
	 header("location:err_insert_user.php?err=$err");
	}
else*/
if( $nme =="" || 	$surnme =="" ||	 $tel ==""  ||  $email =="" || $pos_nme ==""|| $level_nme =="")
{
	  $err = "กรุณากรอกข้อมูลให้ครบครับ";
       header("location:insert_user_confirm.php?err=$err");
}
else
{
 $date_update = date("Y/m/d");
 //$objConnect = odbc_connect("leave","","") or die("Error Connect to Database");
  include 'connectAccess.php'; // เชื่อต่อใหม่
 $strInsert = "insert into confirm_send (NAME, SURNAME, POS_NME, LEVEL_NME, TEL, E_MAIL, CTL_ORG_CDE, DATE_SEND) values ('$nme','$surnme', '$pos_nme','$level_nme','$tel','$email','$cde','$date_update')";
 $objEx = odbc_exec($objConnect,$strInsert) or dir (	header ("location:err_insert_user.php?err='บันทึกผู้ส่งข้อมูลไม่ได้ '"));
//$objEx = odbc_exec($objConnect,$strInsert) or die ("Error Execute [".$strInsert."]");
		 $objConnect = odbc_connect("leave","","") or die("Error Connect to Database");
     //เปลี่ยนสถานะทีสังกัดเป็น 1 เพื่อให้ดูข้อมูลได้อย่างเดียว
        $strSQL = "UPDATE CTL_ORG_DOL SET STATUS =  1 WHERE CTL_ORG_CDE = '$cde' ";
    	$objExec = odbc_exec($objConnect, $strSQL) or die ("Error Execute [".$strSQL."]");
       if ($objExec)
	   {
	    $message =$orgName."ยืนยันการส่งแล้ว";
         $_SESSION["STATUS"] = 1;
	   }
	   else
			$message = $orgName."ส่งไม่ได้ กรุณาติดต่อเจ้าหน้าที่ ";
}
			odbc_close($objConnect);  
?>
<!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=windows-874" />
	<title> ยืนยันการบันทึก  </title>
	</head>
	<link rel="stylesheet" type="text/css" href="mycss2.css">
	<body  onLoad= "javascript:if(confirm('ผลการทำงาน<?=$message?>?') == true) {window.location = 'index_user.php';}">
	<? include ("header.php")?>
	<table  id = "newspaper-b" align="center" border ="0"  width="800">
	<tr align = "center"><th colspan = "2">    ผลการทำงาน <th></tr>
	<tr align = "center" >  <th><font color = "red" colspan = "2">  <?= $message?> </font></th></tr>
				<tr >
			
					<td align = "right"> <a href = 'index_user.php'> หน้าหลัก     </td>
					<td align = "left"> <a href = "#" onClick= "javascript:if(confirm('คุณต้องการออกจากระบบ?') == true) {window.location = 'index.php';}">    ออกจากระบบ</a> </td>
				</tr>
	</table>
	
	</body>
	</html>
 
 
 
 รันแล้วขึ้นผลลัพธ์ดังนี้
 
 Code
 
 Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\AppServ\www\leave\confirm_suscess.php:1) in C:\AppServ\www\leave\confirm_suscess.php on line 2
 Strict Standards: date() [function.date]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Krasnoyarsk' for '7.0/no DST' instead in C:\AppServ\www\leave\confirm_suscess.php on line 41
 
 Warning: odbc_connect() [function.odbc-connect]: SQL error: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified, SQL state IM002 in SQLConnect in C:\AppServ\www\leave\confirm_suscess.php on line 48
 Error Connect to Database
 
 
 
 Tag : PHP
 
 
 |  
            |  |  
            | 
              
                |  |  |  |  
                |  | 
                    
                      | Date :
                          2012-10-10 13:07:40 | By :
                          pompam_angril | View :
                          1038 | Reply :
                          1 |  |  |  
                |  |  |  |  |  
            |  |  
		            |  |  
		|  |  |  |  |  
  
    | 
 
        
          |  |  |  |  |  
          |  |  | 
            
              | Code (PHP) 
 <?php
if(!isset($_SESSION)) {@ob_start(); @session_start();} 
//ob_start();
//session_start();
// $status = $_SESSION["STATUS"];
$cde = $_SESSION["CTL_CDE"];
$nameOrg = $_SESSION["CTL_NME"];
// $cde = $_REQUEST["$cde"];
// $nameOrg = $_REQUEST["$nameOrg"];
$nme = $_REQUEST["nme"];
$surnme = $_REQUEST["surnme"];
$tel = $_REQUEST["tel"];
$email = $_REQUEST["e_mail"];
$level_nme = $_REQUEST["level_nme"];
$pos_nme = $_REQUEST["pos_nme"];
// echo "cde".$cde."<br>";
//	 echo "name".$nameOrg."<br>";
//	 echo "name".$nme."<br>";
//	 echo "surname".$surnme."<br>";
//	 echo "tel".$tel."<br>";
//	 echo "e_mail".$e_mail."<br>";
// เพิ่มข้อมูลผู้แจ้ง
/*if($id == "" || $pos_id == "" || $prefix_name =="" || $nme=="" || $surnme=="" || $cde =="" || $id_card =="" || $per_typ=="")
{
$err = "กรุณากรอกข้อมูลให้ครบครับ";
header("location:err_insert_user.php?err=$err");
}
else*/
if( $nme =="" || $surnme =="" ||	 $tel =="" || $email =="" || $pos_nme ==""|| $level_nme =="")
{
$err = "กรุณากรอกข้อมูลให้ครบครับ";
header("location:insert_user_confirm.php?err=$err");
}
else
{
date_default_timezone_set('Asia/Bangkok'); // เพิ่ม time zone ครับ
$date_update = date("Y/m/d");
//$objConnect = odbc_connect("leave","","") or die("Error Connect to Database");
include 'connectAccess.php'; // เชื่อต่อใหม่
$strInsert = "insert into confirm_send (NAME, SURNAME, POS_NME, LEVEL_NME, TEL, E_MAIL, CTL_ORG_CDE, DATE_SEND) values ('$nme','$surnme', '$pos_nme','$level_nme','$tel','$email','$cde',CURDATE() )"; // ตรงนี้เปลี่ยนจาก $date_update เป็น CURDATE() ดูครับ
$objEx = odbc_exec($objConnect,$strInsert) or dir (	header ("location:err_insert_user.php?err='บันทึกผู้ส่งข้อมูลไม่ได้ '"));
//$objEx = odbc_exec($objConnect,$strInsert) or die ("Error Execute [".$strInsert."]");
$objConnect = odbc_connect("leave","","") or die("Error Connect to Database");
//เปลี่ยนสถานะทีสังกัดเป็น 1 เพื่อให้ดูข้อมูลได้อย่างเดียว
$strSQL = "UPDATE CTL_ORG_DOL SET STATUS = 1 WHERE CTL_ORG_CDE = '$cde' ";
$objExec = odbc_exec($objConnect, $strSQL) or die ("Error Execute [".$strSQL."]");
if ($objExec)
{
$message =$orgName."ยืนยันการส่งแล้ว";
$_SESSION["STATUS"] = 1;
}
else
$message = $orgName."ส่งไม่ได้ กรุณาติดต่อเจ้าหน้าที่ ";
}
odbc_close($objConnect); 
?>
<!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=windows-874" />
<title>ยืนยันการบันทึก</title>
</head>
<link rel="stylesheet" type="text/css" href="mycss2.css">
<body onLoad= "javascript:if(confirm('ผลการทำงาน<?=$message?>?') == true) {window.location = 'index_user.php';}">
<? include ("header.php")?>
<table id = "newspaper-b" align="center" border ="0" width="800">
  <tr align = "center">
    <th colspan = "2"> ผลการทำงาน
    
    <th>
  </tr>
  <tr align = "center" >
    <th><font color = "red" colspan = "2">
      <?= $message?>
      </font></th>
  </tr>
  <tr >
    <td align = "right"><a href = 'index_user.php'> หน้าหลัก </td>
    <td align = "left"><a href = "#" onClick= "javascript:if(confirm('คุณต้องการออกจากระบบ?') == true) {window.location = 'index.php';}"> ออกจากระบบ</a></td>
  </tr>
</table>
</body>
</html>
ลองดูนะครับ
 
 Code
 
 Warning: odbc_connect() [function.odbc-connect]: SQL error: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified, SQL state IM002 in SQLConnect in C:\AppServ\www\leave\confirm_suscess.php on line 48Error Connect to Database // ตรงนี้มัน connect db ไม่ได้ลองตรวจสอบเรื่องการ connect ดูครับ
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2012-10-10 17:41:08 | By :
                            pokultra |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  |  |