我做了一個註冊碼電子郵件,用戶,傳遞,當我點擊「zr」在數據庫中插入此信息,但我得到以下錯誤:PHP,MySQL錯誤:列計數與第1行的值計數不匹配
MySQL error: Column count doesn’t match value count at row 1
代碼:
include ('config.php');
include('login_css.php');
$error = "";
if (isset($_POST['zr'])){
$date = date("m d Y");
$user_name = strip_tags($_POST['user']);
$user_pass = strip_tags($_POST['pass']);
$user_email = strip_tags($_POST['email']);
$empty = strip_tags($_POST['none']);
$empty.= strip_tags($_POST['none']);
$empty.= strip_tags($_POST['none']);
$day = strip_tags($_POST['day']);
$month = strip_tags($_POST['month']);
$year = strip_tags($_POST['year']);
$dob = "$day/$month/$year";
if ($user_name == "") {
$error = "Firstname cannot be left empty.";
echo $error;
}
else if ($user_pass == "") {
$error = "Lastname cannot be left empty.";
echo $error;
}
else if ($user_email == "") {
$error = "Email cannot be left empty.";
echo $error;
}
//Check the username doesn't already exist
$check_username = mysql_query("SELECT yser FROM users WHERE username='$user_name'");
$numrows_username = mysql_num_rows($check_username);
if ($numrows_username != 0) {
$error = 'That username has already been registered.';
echo $error;
}
else
{
$check_email = mysql_query("SELECT email FROM users WHERE email='$user_email'");
$numrows_email = mysql_num_rows($check_email);
if ($numrows_email != 0) {
$error = 'That email has already been registered.';
echo $error;
}
else
{
//Register the user
$register = mysql_query("INSERT INTO users(user,pass,email) VALUES('','$user_name','$user_pass','$user_email','$date')") or die(mysql_error());
die('Registered successfully!');
}
}
}
?>
<!-- Form Mixin-->
<!-- Input Mixin-->
<!-- Button Mixin-->
<!-- Pen Title-->
<div class="pen-title">
<title>WebooHub - Join</title>
<h1>WebooHub - Join</h1>
</div>
<!-- Form Module-->
<div class="module form-module">
<div class="toggle"><i class="fa fa-times fa-pencil"></i>
</div>
<div class="form">
<h2>Create Your Account</h2>
<form action="u_register" method="POST">
<button>Join Now</button>
</form>
</div>
<div class="cta"><a href="login.php">Login?</a></div>
</div><strong></strong>
@FakhruddinUjjainwala我最近注意到你發佈了一個答案和評論。 OP將會看到你的答案,不需要評論。 –
同樣的錯誤:@FakhruddinUjjainwala Ujjainwala警告:mysql_num_rows():提供的參數不是第33行中的C:\ AppServ \ www \ Weboo \ WeboHub \ app \ join \ u_register.php中的有效MySQL結果資源 列數不匹配第1行的值計數 –
[您的腳本存在SQL注入攻擊風險。](http://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php) –