title: can't update MySQL table by PHP session
body: <p>I can't update the MySQL table by value get from PHP session. I tested the valued got by PHP session is ok, and I also find there is the problem in <code>$sql_query1</code> in my code , but I can't fix it.</p>
  
  <p>Here is the code:</p>
  
  <p><strong>MySQL schema↓</strong></p>
  
  <pre><code>CREATE TABLE `test` (
    `class` int(50) DEFAULT NULL ,
    `class_group` int(50) DEFAULT NULL,
    `name` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
    `addr` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
    `seq` int(50) NOT NULL,
    `survey` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
    `survey_status` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
    `survey_date` date DEFAULT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
  
  INSERT INTO `test` (`class`, `class_group`, `name`, `addr`, `seq`, `survey`, `survey_status`, `survey_date`) VALUES
  (1, 0, 'Michael　　', 'USA', 10, '', '', '0000-00-00'),
  (1, 0, 'Jordan　　', 'CAN', 20, '', '', '0000-00-00');
  
  ALTER TABLE `test`
    ADD PRIMARY KEY (`seq`);
  </code></pre>
  
  <p><strong>index.php↓</strong></p>
  
  <pre><code>&lt;?php
  session_start();
  ?&gt;
  
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;body&gt;
  
    &lt;h2 align="center"&gt;Update_System&lt;/h2&gt;
  
  &lt;form action="2_update.php" method="get"&gt;
    &lt;fieldset&gt;
    &lt;legend&gt;&lt;h2&gt;System&lt;/h2&gt;&lt;/legend&gt;&lt;br/&gt;
    seq： &lt;input type="text" name="seq"&gt;&lt;br/&gt;
    survey： &lt;input type="text" name="survey"&gt;&lt;/br&gt;
    survey_status： &lt;input type="text" name="survey_status"&gt;&lt;br/&gt;
    survey_date： &lt;input type="text" name="survey_date"&gt;&lt;br/&gt;
    &lt;/fieldset&gt;
    &lt;br&gt;
    &lt;input type="submit" name="submit" value="submit"&gt;
  &lt;/form&gt;
  &lt;br&gt;
  &lt;form action="1_test_preview.php" method="POST"&gt;
  &lt;input type="submit" name="submit_preview" value="preview list"&gt;
  &lt;/form&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>preview.php↓</strong></p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;body&gt;
  &lt;h2 align="center"&gt;Result&lt;/h2&gt;
  
  &lt;?php
  if(isset($_POST['submit_preview'])){
  
  $conn=mysql_connect("localhost","root","");
  if (!$conn){die ("can not connect" . mysql_error());}
  mysql_select_db("fs_change",$conn);
  mysql_query("SET NAMES 'UTF8'");
  mysql_query("set character set 'utf8'");
  
  //set db connection
  $sql_query1="select * from test";
  $sql_nrow="select count(*) from test";
  $result=mysql_query($sql_query1, $conn); 
  $row_result=mysql_fetch_assoc($result); 
  }
  ?&gt;
  &lt;form id="form1" name="form1"&gt;
  &lt;table border="1" align="center"&gt;
  &lt;tr&gt;
  &lt;td&gt;class&lt;/td&gt;
  &lt;td&gt;class_group&lt;/td&gt;
  &lt;td&gt;name&lt;/td&gt;
  &lt;td&gt;addr&lt;/td&gt;
  &lt;td&gt;seq&lt;/td&gt;
  &lt;td&gt;survey&lt;/td&gt;
  &lt;td&gt;survey_status&lt;/td&gt;
  &lt;td&gt;survey_date&lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;?php do { ?&gt;
  
  &lt;tr&gt;
  &lt;td&gt;&lt;?php echo $row_result['class']; ?&gt;&lt;/td&gt;
  &lt;td&gt;&lt;?php echo $row_result['class_group']; ?&gt;&lt;/td&gt;
  &lt;td&gt;&lt;?php echo $row_result['name']; ?&gt;&lt;/td&gt;
  &lt;td&gt;&lt;?php echo $row_result['addr']; ?&gt;&lt;/td&gt;
  &lt;td&gt;&lt;?php echo $row_result['seq']; ?&gt;&lt;/td&gt;
  &lt;td&gt;&lt;?php echo $row_result['survey']; ?&gt;&lt;/td&gt;
  &lt;td&gt;&lt;?php echo $row_result['survey_status']; ?&gt;&lt;/td&gt;
  &lt;td&gt;&lt;?php echo $row_result['survey_date']; ?&gt;&lt;/td&gt;
  
  &lt;?php } while ($row_result = mysql_fetch_assoc($result));?&gt;
  &lt;tr&gt;
  
  &lt;/table&gt;
  &lt;/form&gt; 
  
  &lt;?php
  mysql_free_result($result); 
  ?&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>update.php↓</strong></p>
  
  <pre><code>&lt;?php
  //get the data from session
  session_start();
  if(isset($_GET['seq'])){$_SESSION['seq']=$_GET['seq'];}
  if(isset($_GET['survey'])){$_SESSION['survey']=$_GET['survey'];}
  if(isset($_GET['survey_status'])){$_SESSION['survey_status']=$_GET['survey_status'];}
  if(isset($_GET['survey_date'])){$_SESSION['survey_date']=$_GET['survey_date'];}
  
  
  
  //set variables
      $seq = $_SESSION['seq'];
      $survey = $_SESSION['survey'];
      $survey_status = $_SESSION['survey_status'];
      $survey_date = $_SESSION['survey_date'];
  
  //set db connection  
  if(isset($_GET['submit'])){
  
  $conn=mysql_connect("localhost","root","");
  if (!$conn){die ("can not connect" . mysql_error());}
  mysql_select_db("fs_change",$conn);
  mysql_query("SET NAMES 'UTF8'");
  mysql_query("set character set 'utf8'");
  
  //set sql query
  $sql_query1="UPDATE fs SET survey = $survey, survey_status = $survey_status, survey_date = $survey_date WHERE seq = $seq";
  mysql_query($sql_query1, $conn);
  mysql_close($conn);
  } 
  ?&gt;
  
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;body&gt;
      test sql_query1：
      &lt;?php 
      if ($sql_query1 === TRUE) {
      echo 'Updated Successfully'
      ;}
      else {echo "Update Failed";}
      ?&gt; &lt;br&gt;
      seq：&lt;?php echo $seq?&gt;&lt;br&gt;
      survey：&lt;?php echo $survey?&gt;&lt;br&gt;
      survey_state：&lt;?php echo $survey_status?&gt;&lt;br&gt;
      survey_date：&lt;?php echo $survey_date?&gt;&lt;br&gt;
      &lt;input type = "button" name = "return" value = "back" onclick= "history.back()"&gt; &amp;nbsp;
      &lt;/form&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>