PHP傳值問題 請問我這段程式碼為什麼沒辦法傳值給下一頁 下一頁ehco不出來

edited 九月 2014 in PHP新手區
<?php require_once('Connections/ieqa.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']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "formAdd")) {
  $insertSQL = sprintf("INSERT INTO questionnaire (School_system, `year`, Department, sex, Hours, a1other, a2other, a3other, a4other, a5other, a6other, a7other, a8other, a9other, a10other, `Local`, Mode, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, `time`) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['School_system'], "text"),
                       GetSQLValueString($_POST['year'], "text"),
                       GetSQLValueString($_POST['Department'], "text"),
                       GetSQLValueString($_POST['sex'], "text"),
                       GetSQLValueString($_POST['Hours'], "text"),
                       GetSQLValueString(isset($_POST['a1other']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString(isset($_POST['a2other']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString(isset($_POST['a3other']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString(isset($_POST['a4other']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString(isset($_POST['a5other']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString(isset($_POST['a6other']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString(isset($_POST['a7other']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString(isset($_POST['a8other']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString(isset($_POST['a9other']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString(isset($_POST['a10other']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString($_POST['Local'], "text"),
                       GetSQLValueString($_POST['Mode'], "text"),
                       GetSQLValueString($_POST['Q1'], "text"),
                       GetSQLValueString($_POST['Q2'], "text"),
                       GetSQLValueString($_POST['Q3'], "text"),
                       GetSQLValueString($_POST['Q4'], "text"),
                       GetSQLValueString($_POST['Q5'], "text"),
                       GetSQLValueString($_POST['Q6'], "text"),
                       GetSQLValueString($_POST['Q7'], "text"),
                       GetSQLValueString($_POST['Q8'], "text"),
                       GetSQLValueString($_POST['time'], "date"));

  mysql_select_db($database_ieqa, $ieqa);
  $Result1 = mysql_query($insertSQL, $ieqa) or die(mysql_error());

  $insertGoTo = "qa2.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}
?>
Sign In or Register to comment.