|  | 
	                
  
    | 
	 
        เพิ่มดาต้าเบสไม่ได้ ขึ้นColumn count doesn\'t match value count at row 1ช่วยดูโค๊ตให้หน่อยค่ะ     |  
    |  |  
 
	
		|  |  |  |  |  
		|  |  | 
          
            | Code (PHP) 
 <?php require_once('Connections/tast.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }
  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form_report_ploblem")) {
  $insertSQL = sprintf("INSERT INTO repair (Machinetype,Problem,Station,Timestamp) VALUES (%s, %s)",
  				  GetSQLValueString($_POST['Machinetype'],"text"),
				     GetSQLValueString($_POST['Problem'],"text"),                       
					   GetSQLValueString($_POST['Station'], "text"),
                       GetSQLValueString($_POST['hiddenField'], "date"));
  mysql_select_db($database_tast, $tast);
  $Result1 = mysql_query($insertSQL, $tast) or die(mysql_error());
}
mysql_select_db($database_tast, $tast);
$query_Recordset1 = "SELECT * FROM repair";
$Recordset1 = mysql_query($query_Recordset1, $tast) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>แจ้งซ่อมออนไลน์</title>
</head>
<body>
<form action="<?php echo $editFormAction; ?>" name="form_report_ploblem" method="POST">
 
  <table border="1" width="56%">
<tr>
<td colspan="2"><center><h1>แจ้งซ่อมออนไลน์</h1></center></td>
</tr>
<tr>
<td width="106" valign="top">
<center>
  <label for="textfield"></label>
  <?php
$handle = @fopen("../Problem/Machine_items.txt", "r");
$mac_type="";
if ($handle) {
	$num_row=0;
    while (($buffer = fgets($handle, 4096)) !== false) {
		$num_row++;				
        if(substr(trim($buffer),0,1)!="#" && $num_row>=2){
									
			$mac_data = explode(",", $buffer);//<== แยกข้อความ เพื่อเก็บลงในอาร์เรย์
			if($mac_type!=$mac_data[0]){//เปรียบเทียบค่ากับบรรทัดก่อนหน้า เพื่อไม่ให้ข้อมูลซ้ำกัน			
			$mac_type = $mac_data[0]; //<==เก็บค่าตัวแปรในบรรทัดปัจจุบัน เพื่อเปรียบเทียบกับบรรทัดก่อนหน้า						
			echo "<h3><a href='?tap=1&Machinetype=".$mac_data[0]."'>".$mac_data[0].'</a></h3>'; // machin name
			
			//echo $mac_data[1]; // machin ploblem
			
			}
		}	
    }
    if (!feof($handle)) {
        echo "Error: unexpected fgets() fail\n";
    }
    fclose($handle);
}
?>
</center></td>
<td width="167" valign="top">
  <p>
    
    <?php
if($_GET['Machinetype']!=""){
$handle = @fopen("../Problem/Machine_items.txt", "r");
$mac_type="";
if ($handle) {
    while (($buffer = fgets($handle, 4096)) !== false) {		
        if(substr(trim($buffer),0,1)!="#"){
									
			$mac_data = explode(",", $buffer);//<== แยกข้อความ เพื่อเก็บลงในอาร์เรย์
						
			if(urldecode(trim($_GET['Machinetype']))==urldecode(trim($mac_data[0]))){
				
				echo  '
				<h3><input type="radio" name="Problem" id="radio" value="'.$mac_data[1].'" style="float:left;" />';
				echo $mac_data[1].'</h3>';
				
				
			}
		}
    }
    if (!feof($handle)) {
       
	    echo "Error: unexpected fgets() fail\n";
    }
    fclose($handle);
}
		echo '  <p>
		 
    	
		
		<input type="submit" name="button" id="button" value="sent" />
    	<input type="reset" name="button2" id="button2" value="cancal">
  </p>';	
}
   
?>
  </p>
  <p>
     <input type="hidden" name="hiddenField" id="hiddenField">
    <input name="Station" type="hidden" value="555">
  </p></td>
</tr>
</table>
  <input type="hidden" name="MM_insert" value="form_report_ploblem">
</form>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>
 
 
 Tag : PHP
 
 
 |  
            |  |  
            | 
              
                |  |  |  |  
                |  | 
                    
                      | Date :
                          2015-07-10 08:37:10 | By :
                          peachzasaa | View :
                          856 | Reply :
                          4 |  |  |  
                |  |  |  |  |  
            |  |  
		            |  |  
		|  |  |  |  |  
  
    | 
 
        
          |  |  |  |  |  
          |  |  | 
            
              | Code 
 $insertSQL = sprintf("INSERT INTO repair 
(Machinetype,Problem,Station,Timestamp) 
VALUES (%s, %s,%s, %s)",
GetSQLValueString($_POST['Machinetype'],"text"),
GetSQLValueString($_POST['Problem'],"text"), 
GetSQLValueString($_POST['Station'], "text"),
GetSQLValueString($_POST['hiddenField'], "date"));
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2015-07-10 08:43:54 | By :
                            Chaidhanan |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ขอบคุณค่ะได้แล้วค่ะ ขอถามเพิ่มเติ่มอีกนิดนึง
 คือต้องใส่ Hidden เข้าไปยังไงให้ข้อมูล Machine จาก textเข้ามาในดาด้าเบสนะค่ะ
 คือต้องวางตรงไหน แล้วพิมยังไงน่ะคะ
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2015-07-10 08:53:40 | By :
                            peachzasaa |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
 
        
          |  |  |  |  |  
          |  |  | 
            
              | กดปุ่ม sent แล้วให้ไปอีกหน้านึงเขียนโค้ดแบบนี้ถูกไหมคะ 
 <a href="fromtwo.php" target="rightframe"><input type="button" value="sent" /></a>
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2015-07-10 09:36:51 | By :
                            peachzasaa |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  |  |