|
 |
|
insert ไม่เข้า แล้วขึ้นว่า Column count doesn't match value count at row 1 ช่วยทีคับ |
|
 |
|
|
 |
 |
|
หน้า insert form
Code (PHP)
<form id="form1" name="form1" method="post" action="register_save.php" onsubmit="JavaScript:return fncSubmit();">
<table width="100%" border="0">
<tr>
<td valign="top">ชื่อเข้าระบบ</td>
<td><span class="form_row">
<input type="text" class="form_input" name="txtuser" id="txtuser" /> <font color="#FF0000">*</font>
</span></td>
</tr>
<tr>
<td valign="top">รหัสผ่านระบบ</td>
<td><span class="form_row">
<input type="password" class="form_input" name="txtpass" id="txtpass" /> <font color="#FF0000">*</font>
</span></td>
</tr>
<tr>
<td valign="top">ชื่อ</td>
<td><span class="form_row">
<input type="text" class="form_input" name="txtname" id="txtname" /> <font color="#FF0000">*</font>
</span></td>
</tr>
<tr>
<td valign="top">นามสกุล</td>
<td><span class="form_row">
<input type="text" class="form_input" name="txtsurname" id="txtsurname" /> <font color="#FF0000">*</font>
</span></td>
</tr>
<tr>
<td valign="top">รหัสบัตรประชาชน</td>
<td><span class="form_row">
<input name="txtcode" type="text" class="form_input" id="txtcode" maxlength="13" onblur='checkNumber(this)' />
<font color="#FF0000">*</font>
</span></td>
</tr>
<tr>
<td valign="top">ที่อยู่</td>
<td><span class="form_row">
<textarea class="form_textarea" name="textaadd" id="textaadd"></textarea> <font color="#FF0000">*</font>
</span></td>
</tr>
<tr>
<script type='text/javascript'>
function checkNumber(data){
if(!data.value.match(/^\d*$/)){
alert('กรอกตัวเลขเท่านั้น');
data.value='';
}
}
</script>
<td valign="top">เบอร์โทร</td>
<td><span class="form_row">
<input name="txttel" type="text" class="form_input" id="txttel" maxlength="10" onblur='checkNumber(this)' /> <font color="#FF0000">*</font>
</span></td>
</tr>
<tr>
<script type='text/javascript'>
function check_email(elm){
var regex_email=/^[_a-zA-Z0-9-]+(.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(.[a-zA-Z0-9-]+)*(.([a-zA-Z]){2,4})$/
if(!elm.value.match(regex_email)){
alert('รูปแบบ email ไม่ถูกต้อง');
}
}
</script>
<td valign="top">อีเมล์</td>
<td><span class="form_row">
<input type="text" class="form_input" name="txtemail" id="txtemail" onblur='check_email(this)' /> <font color="#FF0000">*</font>
</span></td>
</tr>
<tr>
<td valign="top"> </td>
<td><div class="form_row">
<input name="Submit" type="submit" class="form_submit" id="Submit" value="สมัครสมาชิก" />
</div></td>
</tr>
</table>
</form>
หน้า insert sql
Code (PHP)
<?php
include 'connect.php';
$id = $_POST["txtuser"];
$pass = $_POST["txtpass"];
$name = $_POST["txtname"];
$surname= $_POST["txtsurname"];
$code = $_POST["txtcode"];
$addr = $_POST["textaadd"];
$tel = $_POST["txttel"];
$email = $_POST["txtemail"];
$sql = "INSERT INTO member VALUES ";
$sql .= "(null,'$id','$pass','$name','$surname','$code','$addr','$tel','$eamil')";
$result = mysql_query($sql) or exit($sql);
exit("<script>
alert('บันทึกเรียบร้อย');
window.location='login.php';
</script>")
?>
แล้วขึ้นว่า Column count doesn't match value count at row 1
ช่วยทีคับ
Tag : PHP, MySQL

|
|
 |
 |
 |
 |
Date :
2012-08-30 12:44:49 |
By :
usakira |
View :
1251 |
Reply :
5 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ค่าที่ต้องการ INSERT กับจำนวนฟิลด์ หรือชื่อฟิลด์ไม่ตรงกันครับ ลองเช็คดูๆ
|
 |
 |
 |
 |
Date :
2012-08-30 13:00:31 |
By :
arm8957 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
การ Insert ควรระบุ Column เข้าไปด้วยครับ
Code (PHP)
$strSQL = "INSERT INTO customer ";
$strSQL .="(CustomerID,Name,Email,CountryCode,Budget,Used) ";
$strSQL .="VALUES ";
$strSQL .="('".$_POST["txtCustomerID"]."','".$_POST["txtName"]."','".$_POST["txtEmail"]."' ";
$strSQL .=",'".$_POST["txtCountryCode"]."','".$_POST["txtBudget"]."','".$_POST["txtUsed"]."') ";
$objQuery = mysql_query($strSQL);
|
 |
 |
 |
 |
Date :
2012-08-30 13:00:38 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
<?php
$objConnect = mssql_connect("localhost","root","1234") or die("Error Connect to Database");
$objDB = mssql_select_db("return");
$strSQL = "INSERT INTO member ";
$strSQL .="(Username,Password,Name,Surname,Code,Address,Tel,Email) ";
$strSQL .="VALUES ";
$strSQL .="('".$_POST["txtuser"]."','".$_POST["txtpass"]."','".$_POST["txtname"]."','".$_POST["txtsurname"]."' ";
$strSQL .=",'".$_POST["txtcode"]."','".$_POST["textadd"]."','".$_POST["txttel"]."','".$_POST["txtemail"]."') ";
$objQuery = mssql_query($strSQL);
if($objQuery)
{
echo "Save Done.";
}
else
{
echo "Error Save [".$strSQL."]";
}
mssql_close($objConnect);
?>
แบบนี้ใช่ไหมคับ ข้อมูลไม่ลงฐานข้อมูลเหมือนเดิมคับ ช่วยที
|
 |
 |
 |
 |
Date :
2012-08-30 19:27:01 |
By :
usakira |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองดูเผื่อได้น่ะ แล้วก็ดูพวกชื่อฟิลด์ในตารางในเบสด้วยว่าตรงกันไหม
Code (PHP)
<?php
$objConnect = mssql_connect("localhost","root","1234") or die("Error Connect to Database");
$objDB = mssql_select_db("return");
$strSQL = "INSERT INTO member (Username,Password,Name,Surname,Code,Address,Tel,Email) VALUES ('".$_POST["txtuser"]."','".$_POST["txtpass"]."','".$_POST["txtname"]."','".$_POST["txtsurname"]."', '".$_POST["txtcode"]."','".$_POST["textadd"]."','".$_POST["txttel"]."','".$_POST["txtemail"]."') ";
$objQuery = mssql_query($strSQL) or die (mysql_error());
if($objQuery){
echo "Save Done.";
} else {
echo "Error Save [".$strSQL."]";
}
mssql_close($objConnect);
?>
|
 |
 |
 |
 |
Date :
2012-08-30 19:48:40 |
By :
บังเอิญผ่านมาเห็น |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่เข้าอ่ะครับ ขึ้นว่า
Fatal error: Call to undefined function mssql_connect() in C:\AppServ\www\retune\register_save.php on line 3
|
 |
 |
 |
 |
Date :
2012-08-31 19:14:57 |
By :
usakira |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|