|
|
|
ค่าที่ต้องการไม่ยอมบันทึกลงฐานข้อมูลค่ะ เป็นค่าว่างค่ะ |
|
|
|
|
|
|
|
Code (PHP)
<?php
ini_set('register_globals','On');
ini_set('session.bug_compat_warn', 0);
ini_set('session.bug_compat_42', 0);
session_start();
header("Content-type: text/html; charset=utf-8");
include "startconnect.inc.php";
date_default_timezone_set('Asia/Bangkok');
$email = $_POST['txtEmail'];
$passregis = $_POST['txtPassRegis'];
$firstname = $_POST['txtFirstname'];
$lastname = $_POST['txtLastname'];
$nickname = $_POST["txtnickname"];
$gender = $_POST["txtgender"];
$member_pic = $_POST['txtmember'];
$user_date =(int) $_POST['txtDate'];
$user_month =(int) $_POST['txtMonth'];
$user_year =(int) $_POST['txtYear'];
$jobtitle = $_POST['txtjobtitle'];
$mobile = $_POST['txtmobile'];
$telephone = $_POST['txttelephone'];
$anumber = $_POST['txtanumber'];
$asoi = $_POST['txtasoi'];
$aroad = $_POST['txtaroad'];
$atumbon = $_POST['selTumbon'];
$aumper = $_POST['selAmphur'];
$aprovince = $_POST['selProvince'];
$azipcode =(int) $_POST['txtazipcode'];
//edit number to text
function dbtext($tb,$ftext,$fid,$val){
$val = mysql_real_escape_string($val);
$rs = mysql_query('select * from '.$tb.' where '.$fid."='$val'");
echo mysql_error();
if (mysql_num_rows($rs)){
$r = mysql_fetch_assoc($rs);
return $r[$ftext];
}else{
return '';
}
}
$atumbon = dbtext('district','DISTRICT_NAME','DISTRICT_ID',$atumbon);
$aumper = dbtext('amphur','AMPHUR_NAME','AMPHUR_ID',$aumper);
$aprovince = dbtext('province','PROVINCE_NAME','PROVINCE_ID',$aprovince);
$member_class_id = 2 ;
$register_date = date("Y-m-d") ;
$register_time = date("G:i:s") ;
$ip_address = $_SERVER['REMOTE_ADDR'] ;
$active = 0 ;
$sql_register = "
insert into tblmember (
email,
password ,
firstname ,
lastname ,
nickname ,
gender,
member_pic,
user_date ,
user_month ,
user_year ,
jobtitle,
mobile,
telephone ,
anumber,
asoi ,
aroad,
atumbon,
aumper,
aprovince,
azipcode ,
member_class_id ,
register_date ,
register_time ,
ip_address ,
active
)
values (
'$email',
'$passregis',
'$firstname',
'$lastname' ,
'$nickname',
'$gender' ,
'$user_date' ,
'$user_month' ,
'$user_year' ,
'$jobtitle',
'$mobile' ,
'$telephone',
'$anumber',
'$asoi',
'$aroad',
'$atumbon',
'$aumper',
'$aprovince',
'$azipcode' ,
'$member_class_id',
'$register_date',
'$register_time',
'$ip_address',
'$active')" ;
//echo $sql_register ;
if ($complete_upload == "yes") {
$result_register = mysql_query($sql_register) or die(mysql_error());
die($sql_register);
}
if($result_register) {
$_SESSION['email'] = NULL;
$_SESSION['passregis'] = NULL;
$email = $_POST['txtEmail'];
header("Location:activate.php?email=$email&active=0");
} else {
die($sql_register);
}
print (mysql_error());
mysql_close($connect);
?>
Tag : PHP
|
|
|
|
|
|
Date :
2012-11-29 13:51:17 |
By :
Nuntida.Nay |
View :
1127 |
Reply :
5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
echo $sql_register;
ลองดูว่าตัวไหนว่างบ้างครับ
|
|
|
|
|
Date :
2012-11-29 14:17:25 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ค่าไหนว่างครับ
แล้วก็ $user_date =(int) $_POST['txtDate']; ไม่ต้องใช้ (int) ก็ได้ครับ
เวลาเอาไป query ก็ ไม่ต้องใส่ '...' ค่าที่ได้ก็จะเป็น int ครับ
EX. insert into tb(int_field,txt_field)values($vay_int,'$var_txt');
|
ประวัติการแก้ไข 2012-11-29 14:18:39
|
|
|
|
Date :
2012-11-29 14:18:10 |
By :
mangkunzo |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ค่ามันไม่บันทึกลงฐานข้อมูลเลยค่ะ
|
|
|
|
|
Date :
2012-11-29 14:19:58 |
By :
Nuntida.Nay |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ลองตรวจสอบ from ที่ส่งค่ามาครับ ชื่อตัวแปรที่ส่งมาอาจจะไม่ตรงกันก็ได้ ลอง echo $_POST["...."] ออกมาดูครับ
|
|
|
|
|
Date :
2012-11-29 15:08:54 |
By :
kokiflam |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|