|
|
|
Column 'RefQid' cannot be null หมายความว่ายังไงครับ code ด้านใน |
|
|
|
|
|
|
|
กดส่งคำตอบแล้วมันขึ้นว่า Column 'RefQid' cannot be null
Code (PHP)
<?php require_once('Connections/apartment.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"] == "form1")) {
$insertSQL = sprintf("INSERT INTO tbanswer (ADetail, AName, AEmail, ADate, RefQid) VALUES (%s, %s, %s, %s, %s)",
GetSQLValueString($_POST['ADetail'], "text"),
GetSQLValueString($_POST['AName'], "text"),
GetSQLValueString($_POST['AEmail'], "text"),
GetSQLValueString($_POST['ADate'], "date"),
GetSQLValueString($_POST['RefQid'], "int"));
mysql_select_db($database_apartment, $apartment);
$Result1 = mysql_query($insertSQL, $apartment) or die(mysql_error());
$insertGoTo = "answer_save.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
$colname_DetailRS1 = "-1";
if (isset($_GET['recordID'])) {
$colname_DetailRS1 = $_GET['recordID'];
}
mysql_select_db($database_apartment, $apartment);
$query_DetailRS1 = sprintf("SELECT * FROM tbquestion WHERE Qid = %s", GetSQLValueString($colname_DetailRS1, "int"));
$DetailRS1 = mysql_query($query_DetailRS1, $apartment) or die(mysql_error());
$row_DetailRS1 = mysql_fetch_assoc($DetailRS1);
$totalRows_DetailRS1 = mysql_num_rows($DetailRS1);
$colname_Recordset2 = "-1";
if (isset($_GET['RefQid'])) {
$colname_Recordset2 = $_GET['RefQid'];
}
mysql_select_db($database_apartment, $apartment);
$query_Recordset2 = sprintf("SELECT * FROM tbanswer WHERE RefQid = %s", GetSQLValueString($colname_Recordset2, "int"));
$Recordset2 = mysql_query($query_Recordset2, $apartment) or die(mysql_error());
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
$totalRows_Recordset2 = mysql_num_rows($Recordset2);
?>
<?php
mysql_free_result($DetailRS1);
mysql_free_result($Recordset2);
?>
Tag : PHP
|
ประวัติการแก้ไข 2013-03-11 12:37:21 2013-03-11 12:39:49
|
|
|
|
|
Date :
2013-03-11 12:37:05 |
By :
patz8899 |
View :
3915 |
Reply :
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
คุณไป insert ค่า null หรือเปล่าครับ ซึ่งมันอาจจะไม่ support ค่า null ครับ
|
|
|
|
|
Date :
2013-03-11 15:07:26 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
มันเป็นการอ้างอิงลำดับที่กระทู้อะครับ
ต้องแก้ต้องไหนหรอครับ
|
|
|
|
|
Date :
2013-03-11 15:25:56 |
By :
patz8899 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ตอนนี้ผมปรับในฐานข้อมูลเป็น null แล้ว
แต่ข้อความมันยังไม่ขึ้นอะครับพี่
|
|
|
|
|
Date :
2013-03-11 15:35:16 |
By :
patz8899 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|