|
 |
|
ต้องการใส่เลขประชาชน 13 หลักค่ะ ใส่ 13 หลักไม่รันให้ ขึ้นError Duplicate entry '2147483647' for key 1 |
|
 |
|
|
 |
 |
|
#ต้องเสร็จวันนี้# 
จะใส่เลขประชาชน 13หลัก แต่โปรแกรม มันรันให้เฉพาะ ไม่เกิน10หลักค่ะ และผลออกมาปกติ
แต่ ! ถ้าใส่เกินจะขึ้นว่า Duplicate entry '2147483647' for key 1
ตั้งเปน Int 14 ก้แ้ล้ว ตอนนี้ int 50 ละตั้งเปน varchar เลขเกิน 14 หมดก็ยังเปนอยู่เลย :( ตอนนี้เลยตั้งประชดไป int(50)
ตั้ง ID เปน primary key คะ
พี่ท่านไหนช่วยได้ ช่วยด้วยคะ จนปัญญาแล้ว

Code (PHP)
<?php require_once('Connections/DB_Connection.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;
}
}
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;
}
}
mysql_select_db($database_DB_Connection, $DB_Connection);
mysql_query("SET character_set_results=utf8");//ตั้งค่าการดึงข้อมูลออกมาให้เป็น utf8
mysql_query("SET character_set_client=utf8");//ตั้งค่าการส่งข้อมุลลงฐานข้อมูลออกมาให้เป็น utf8
mysql_query("SET character_set_connection=utf8");//ตั้งค่าการติดต่อฐานข้อมูลให้เป็น utf8
$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 m4 (ID, lumduw, numaddress, Address, name, Lastname, sex, statushome, birthday, nation, DateIN, DadNo, namedad, momnum, namemom) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['ID'], "int"),
GetSQLValueString($_POST['lumduw'], "int"),
GetSQLValueString($_POST['numaddress'], "text"),
GetSQLValueString($_POST['Address'], "text"),
GetSQLValueString($_POST['name'], "text"),
GetSQLValueString($_POST['Lastname'], "text"),
GetSQLValueString($_POST['sex'], "text"),
GetSQLValueString($_POST['statushome'], "text"),
GetSQLValueString($_POST['birthday'], "date"),
GetSQLValueString($_POST['nation'], "text"),
GetSQLValueString($_POST['DateIN'], "date"),
GetSQLValueString($_POST['DadNo'], "text"),
GetSQLValueString($_POST['namedad'], "text"),
GetSQLValueString($_POST['momnum'], "text"),
GetSQLValueString($_POST['namemom'], "text"));
mysql_select_db($database_DB_Connection, $DB_Connection);
mysql_query("SET character_set_results=utf8");//ตั้งค่าการดึงข้อมูลออกมาให้เป็น utf8
mysql_query("SET character_set_client=utf8");//ตั้งค่าการส่งข้อมุลลงฐานข้อมูลออกมาให้เป็น utf8
mysql_query("SET character_set_connection=utf8");//ตั้งค่าการติดต่อฐานข้อมูลให้เป็น utf8
$Result1 = mysql_query($insertSQL, $DB_Connection) or die(mysql_error());
echo '<meta http-equiv= "refresh" content="0; url=SUSALL.php"/>';
}
?>
Tag : PHP, MySQL

|
|
 |
 |
 |
 |
Date :
2013-10-02 12:19:34 |
By :
Slowykiky |
View :
1714 |
Reply :
4 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
RE : ปรับขนาดค่ะ เผื่ออ่านใหญ่มากตาลาย ลืมคิดไป ว่าSize 10 มันจะใหญ่ขนาดไหน T T
-----------------------------------------------
#ต้องเสร็จวันนี้#
จะใส่เลขประชาชน 13หลัก แต่โปรแกรม มันรันให้เฉพาะ ไม่เกิน10หลักค่ะ และผลออกมาปกติ
แต่ ! ถ้าใส่เกินจะขึ้นว่า Duplicate entry '2147483647' for key 1
ตั้งเปน Int 14 ก้แ้ล้ว ตอนนี้ int 50 ละตั้งเปน varchar เลขเกิน 14 หมดก็ยังเปนอยู่เลย :( ตอนนี้เลยตั้งประชดไป int(50)
ตั้ง ID เปน primary key คะ
พี่ท่านไหนช่วยได้ ช่วยด้วยคะ จนปัญญาแล้ว
|
 |
 |
 |
 |
Date :
2013-10-02 12:21:39 |
By :
Slowykiky |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลอง bigint
หรือ decimal
ครับ
|
 |
 |
 |
 |
Date :
2013-10-02 17:27:46 |
By :
iieszz |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มันเกิดจาก Type ที่เป็น INT รองรับสูงสุดได้ 2147483647 ครับ ลองเปลี่ยนเป็น DECIMAL อย่างที่คุณ iieszz บอกครับ
|
 |
 |
 |
 |
Date :
2013-10-08 08:41:19 |
By :
pantatonic |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 00
|