最新消息無法寫入資料庫

edited 十月 2013 in PHP新手區
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '別, 標題, 時間) VALUES (NULL, NULL, '2006-10-23')' at line 1

在伺服器上會出現此訊息 在我要新增或是修改的時候
可是刪除卻不會出現

可是在單機上卻什麼問題都沒有
以下是我新增的網頁 可以幫我看看哪裡出錯嗎

<?php require_once('Connections/nike.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$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;
if (isset($_SERVER)) {
$editFormAction .= "?" . htmlentities($_SERVER);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO news (類別, 標題, 時間) VALUES (%s, %s, %s)",
GetSQLValueString($_POST, "text"),
GetSQLValueString($_POST, "text"),
GetSQLValueString($_POST, "date"));

mysql_select_db($database_nike, $nike);
$Result1 = mysql_query($insertSQL, $nike) or die(mysql_error());

$insertGoTo = "news.php";
if (isset($_SERVER)) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER;
}
header(sprintf("Location: %s", $insertGoTo));
}

mysql_select_db($database_nike, $nike);
$query_Recordset1 = "SELECT * FROM news";
$Recordset1 = mysql_query($query_Recordset1, $nike) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?><!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=big5">
<title>無標題文件</title>
<style type="text/css">
<!--
body,td,th {
font-size: 16px;
}
.style3 {color: #FFFFFF; }
-->
</style></head>

<body>
<form action="<?php echo $editFormAction; ?>" name="form1" method="POST">
<p>新增記錄</p>
<table width="443" height="81" border="0" cellpadding="0" cellspacing="0">
<tr bgcolor="#0066CC">
<td><div align="center" class="style3">欄位名稱</div></td>
<td><div align="center" class="style3">輸入值</div></td>
</tr>
<tr>
<td><div align="center">類別:</div></td>
<td><input name="類別" type="text" id="類別"></td>
</tr>

<tr>
<td><div align="center">標題 :</div></td>
<td><input name="標題" type="text" id="標題"></td>
</tr>
<tr>
<td><div align="center">時間:</div></td>
<td><input name="時間" type="text" id="時間" value="<?php echo $row_Recordset1; ?>"></td>
</tr>
</table>
<p><font size="2"><a href="news.php">回首頁</a></font></p>
<p>
<input type="submit" name="Submit" value="送出">
<input type="reset" name="Submit2" value="重設">
</p>
<p>
<input type="hidden" name="MM_insert" value="form1">
</p>
</form>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>

原始討論: http://twpug.net/x/modules/newbb/viewtopic.php?topic_id=2218

評論

Sign In or Register to comment.