php mysql ช่วยดูหน่อยครับพอดีมัน insert เข้าฐานข้อมูลไม่ได้ มันขึ้นว่า Can not register อะคับ
มันขึ้นว่า Can not register อะคับ
Code (PHP)
<?php
$strUsername = trim($_POST["tUsername"]);
$strPassword = trim($_POST["tPassword"]);
$strcPassword = trim($_POST["tcPassword"]);
$strName = trim($_POST["tName"]);
$strID = trim($_POST["tID"]);
$strPhone = trim($_POST["tPhone"]);
$strBirthday = trim($_POST["tBirthday"]);
$strEmail = trim($_POST["tEmail"]);
$strBname = trim($_POST["tBname"]);
$strBank = trim($_POST["tBank"]);
$strBnum = trim($_POST["tBnum"]);
$strBtype = trim($_POST["tBtype"]);
$strBox = trim($_POST["tBox"]);
if(trim($strUsername) == "")
{
echo "<div class='alert alert-error'>
<span style='font-size:13px;'><strong>กรุณากรอก ชื่อผู้ใช้งาน</strong></span>
</div>";
exit();
}
if(trim($strPassword) == "")
{
echo "<div class='alert alert-error'>
<span style='font-size:13px;'><strong>กรุณากรอก รหัสผ่าน</strong></span>
</div>";
exit();
}
if($_POST["tPassword"] != $_POST["tcPassword"])
{
echo "<div class='alert alert-error'>
<span style='font-size:13px;'><strong>รหัสผ่านทั้งสองช่องไม่ตรงกัน</strong></span>
</div>";
exit();
}
if(trim($strName) == "")
{
echo "<div class='alert alert-error'>
<span style='font-size:13px;'><strong>กรุณากรอก ชื่อ - นามสกุล</strong></span>
</div>";
exit();
}
if(trim($strBirthday) == "")
{
echo "<div class='alert alert-error'>
<span style='font-size:13px;'><strong>กรุณากรอก วัน / เดือน / ปี เกิด</strong></span>
</div>";
exit();
}
if(trim($strID) == "")
{
echo "<div class='alert alert-error'>
<span style='font-size:13px;'><strong>กรุณากรอกเลขบัตรประจำตัวประชาชน</strong></span>
</div>";
exit();
}
if(trim($strPhone) == "")
{
echo "<div class='alert alert-error'>
<span style='font-size:13px;'><strong>กรุณากรอก เบอร์โทรศัพท์</strong></span>
</div>";
exit();
}
if(trim($strEmail) == "")
{
echo "<div class='alert alert-error'>
<span style='font-size:13px;'><strong>กรุณากรอก E-mail</strong></span>
</div>";
exit();
}
if(trim($strBox) == "")
{
echo "<div class='alert alert-error'>
<span style='font-size:13px;'><strong>กรุณากดยอมรับเงื่อนไขการให้บริการ</strong></span>
</div>";
exit();
}
function Random($length){
$possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
$str = "";
while(strlen($str)<$length){
$str.=substr($possible,(rand()%strlen($possible)),1);
}
return $str;
}
$random = Random(6);
$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
$objDB = mysql_select_db("payment");
$strSQL = "SELECT * FROM member WHERE Username = '".$strUsername."' ";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$objResult = mysql_fetch_array($objQuery);
if($objResult)
{
echo "<div class='alert alert-error'>
<span style='font-size:13px;'><strong>ชื่อผู้ใช้งานนี้มีผู้ใช้ไปแล้วกรุณาเปลี่ยนใหม่</strong></span>
</div>";
}
else
{
$strSQL = "IINSERT INTO `payment`.`member` (`Username` , `Password` ,`Name` ,`id` ,`birthday` ,`phone` ,`Email` ,`bname` ,`bank` ,`bnum` ,`btype` ,`id_member`,`SID` ,`Active`";
$strSQL .="VALUES ('".$strUsername."', '".md5($strPassword)."', '".$strName."', '".$strID."','".$strID."','".$strBirthday."','".$strPhone."','".$strEmail."', '".$strBname."','".$strBank."','".$strBnum."','".$strBtype."','".$random."', '".session_id()."', 'No', NOW( ));";
$objQuery = mysql_query($strSQL);
if($objQuery)
{
echo "xx";
}
else
{
echo "<font color=red>**</font> Can not register";
}
}
mysql_close($objConnect);
?>
Tag : PHP
Date :
2013-01-31 00:42:45
By :
nukedonut1
View :
1308
Reply :
9
มันฟ้องว่า?
Date :
2013-01-31 01:21:50
By :
matay107
บรรทัดที่ 106 ครับ insert มี i แค่ตัวเดียวพอครับไม่ต้องเบิ้ล
Date :
2013-01-31 01:28:52
By :
matay107
Code (PHP)
mysql_query($strSQL) or die(mysql_error());
ลองดู error อาจจะช่วยได้ครับ
Date :
2013-01-31 08:46:48
By :
mr.win
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 ('test', '098f6bcd4621d373cade4e832627b4f6', 'test', 'test','test','te' at line 1
Date :
2013-01-31 20:50:16
By :
nukedonut1
ผิดตรง sql insert อ่า จำนวน value กับค่าที่ส่งไปมันไม่เท่ากันครับ
คุณประกาศไว้ 13 แต่คุณ ใส่ค่า value เกิน
Date :
2013-01-31 21:20:15
By :
lin2online
Code
$strSQL = "IINSERT INTO `payment`.`member` (`Username` , `Password` ,`Name` ,`id` ,`birthday` ,`phone` ,`Email` ,`bname` ,`bank` ,`bnum` ,`btype` ,`id_member`,`SID` ,`Active` ) ";
Date :
2013-01-31 21:42:35
By :
xbeginner01
Column count doesn't match value count at row 1
Date :
2013-01-31 22:23:09
By :
nukedonut1
เหตุผลที่ขึ้น warning นั้นอ่านที่ no 5 ครับ
Date :
2013-01-31 22:28:42
By :
xbeginner01
ได้ละคับขอบคุรคับ
Date :
2013-01-31 22:35:34
By :
nukedonut1
Load balance : Server 02