|
|
|
สอบถามหน่อยครับ ผมไม่รู้จะแก้ยังไง พอดีผมเพิ่งหัดทำ Unknown column 'id' in 'where clause' |
|
|
|
|
|
|
|
Code (PHP)
<?php require_once('../Connections/myconnect.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_update"])) && ($_POST["MM_update"] == "form1")) {
$updateSQL = sprintf("UPDATE book SET name_book=%s, name_do=%s, techer=%s, `year`=%s WHERE id-book=%s",
GetSQLValueString($_POST['name_book'], "text"),
GetSQLValueString($_POST['name_do'], "text"),
GetSQLValueString($_POST['techer'], "text"),
GetSQLValueString($_POST['year'], "date"),
GetSQLValueString($_POST['idbook'], "int"));
mysql_select_db($database_myconnect, $myconnect);
$Result1 = mysql_query($updateSQL, $myconnect) or die(mysql_error());
$updateGoTo = "viwe - book.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
$updateSQL = sprintf("UPDATE book SET name_book=%s, name_do=%s, techer=%s, `year`=%s WHERE id-book=%s",
GetSQLValueString($_POST['name_book'], "text"),
GetSQLValueString($_POST['name_do'], "text"),
GetSQLValueString($_POST['techer'], "text"),
GetSQLValueString($_POST['year'], "date"),
GetSQLValueString($_POST['idbook'], "int"));
mysql_select_db($database_myconnect, $myconnect);
$Result1 = mysql_query($updateSQL, $myconnect) or die(mysql_error());
$updateGoTo = "edit - book.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
$maxRows_bookset = 10;
$pageNum_bookset = 0;
if (isset($_GET['pageNum_bookset'])) {
$pageNum_bookset = $_GET['pageNum_bookset'];
}
$startRow_bookset = $pageNum_bookset * $maxRows_bookset;
$colname_bookset = "-1";
if (isset($_GET['id-book'])) {
$colname_bookset = $_GET['id-book'];
}
mysql_select_db($database_myconnect, $myconnect);
$query_bookset = sprintf("SELECT * FROM book WHERE id-book = %s", GetSQLValueString($colname_bookset, "int"));
$query_limit_bookset = sprintf("%s LIMIT %d, %d", $query_bookset, $startRow_bookset, $maxRows_bookset);
$bookset = mysql_query($query_limit_bookset, $myconnect) or die(mysql_error());
$row_bookset = mysql_fetch_assoc($bookset);
if (isset($_GET['totalRows_bookset'])) {
$totalRows_bookset = $_GET['totalRows_bookset'];
} else {
$all_bookset = mysql_query($query_bookset);
$totalRows_bookset = mysql_num_rows($all_bookset);
}
$totalPages_bookset = ceil($totalRows_bookset/$maxRows_bookset)-1;
?>
<?php
mysql_free_result($bookset);
?>
Tag : PHP
|
ประวัติการแก้ไข 2013-09-19 01:29:38
|
|
|
|
|
Date :
2013-09-19 01:27:26 |
By :
sdbs |
View :
2596 |
Reply :
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<?php require_once('../Connections/myconnect.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_update"])) && ($_POST["MM_update"] == "form1")) {
$updateSQL = sprintf("UPDATE book SET name_book=%s, name_do=%s, techer=%s, `year`=%s WHERE id-book=%s",
GetSQLValueString($_POST['name_book'], "text"),
GetSQLValueString($_POST['name_do'], "text"),
GetSQLValueString($_POST['techer'], "text"),
GetSQLValueString($_POST['year'], "date"),
GetSQLValueString($_POST['idbook'], "int"));
mysql_select_db($database_myconnect, $myconnect);
$Result1 = mysql_query($updateSQL, $myconnect) or die(mysql_error());
$updateGoTo = "viwe - book.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
$updateSQL = sprintf("UPDATE book SET name_book=%s, name_do=%s, techer=%s, `year`=%s WHERE id-book=%s",
GetSQLValueString($_POST['name_book'], "text"),
GetSQLValueString($_POST['name_do'], "text"),
GetSQLValueString($_POST['techer'], "text"),
GetSQLValueString($_POST['year'], "date"),
GetSQLValueString($_POST['idbook'], "int"));
mysql_select_db($database_myconnect, $myconnect);
$Result1 = mysql_query($updateSQL, $myconnect) or die(mysql_error());
$updateGoTo = "edit - book.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
$maxRows_bookset = 10;
$pageNum_bookset = 0;
if (isset($_GET['pageNum_bookset'])) {
$pageNum_bookset = $_GET['pageNum_bookset'];
}
$startRow_bookset = $pageNum_bookset * $maxRows_bookset;
$colname_bookset = "-1";
if (isset($_GET['id-book'])) {
$colname_bookset = $_GET['id-book'];
}
mysql_select_db($database_myconnect, $myconnect);
$query_bookset = sprintf("SELECT * FROM book WHERE id-book = %s", GetSQLValueString($colname_bookset, "int"));
$query_limit_bookset = sprintf("%s LIMIT %d, %d", $query_bookset, $startRow_bookset, $maxRows_bookset);
$bookset = mysql_query($query_limit_bookset, $myconnect) or die(mysql_error());
$row_bookset = mysql_fetch_assoc($bookset);
if (isset($_GET['totalRows_bookset'])) {
$totalRows_bookset = $_GET['totalRows_bookset'];
} else {
$all_bookset = mysql_query($query_bookset);
$totalRows_bookset = mysql_num_rows($all_bookset);
}
$totalPages_bookset = ceil($totalRows_bookset/$maxRows_bookset)-1;
?>
|
|
|
|
|
Date :
2013-09-19 01:28:22 |
By :
sdbs |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
นำเฉพาะส่วนที่โค๊ดมีปัญหามาดีกว่าครับ ยาวเกิ้ล
แนะนำ Unknown column 'id' in 'where clause' = ไม่มีคอลัม id
|
|
|
|
|
Date :
2013-09-19 08:58:38 |
By :
Ex-[S]i[L]e[N]t |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เมื่อไหร่หนังสือไทยหรือเว็บไซต์หลาย ๆ แห่งจะเลิกสอนให้ใช้ Dreamweaver เขียน PHP ซะทีครับ ผมว่ามันทำให้คนเรียนรู้ช้าน่ะ
|
|
|
|
|
Date :
2013-09-19 09:03:31 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอดู column ใน ตาราง book หน่อยครับ มี column อะไรบ้าง
|
|
|
|
|
Date :
2013-09-19 10:18:55 |
By :
anotherdie |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ป....แนะนำว่าเริ่มนับ 1 ใหม่ตั้งแต่ กระบวนการสร้างฐานข้อมูล การตั้งชื่อให้ง่ายๆสั้นๆสอดคล้อง บลา บลา บลา บลา ฮ่า ๆ ๆ (เข้ามาป่วนเฉย ๆ อย่าโกรธกันนะ)
ช่วยแปลให้
Unknown column 'id' in 'where clause'
แปลว่า ไม่มี คอลัมภ์ที่ชื่อว่า id ในตารางที่ชื่อ clause ครับ
มันก็ตรงๆตัวอยู่แล้ว เหอะ ๆ
|
|
|
|
|
Date :
2013-09-23 18:15:04 |
By :
apisitp |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|