gpt4 book ai didi

PHP,错误 1136 : Column count doesn't match value count at row 1

转载 作者:行者123 更新时间:2023-11-29 03:51:44 25 4
gpt4 key购买 nike

<分区>

我得到这个异常:

Error 1136 : Column count doesn't match value count at row 1

表的结构:

create table gb_entries (
id int(4) not null auto_increment,
username varchar(40) not null,
name varchar(40),
gender varchar(40),
dob int(40),
email varchar(40),
primary key (id)
);

使用这段 PHP 代码:

// Add a new entry to the database
function addEntry($username, $name, $gender, $dob, $email) {
$connection = mysql_open();
$insert = "insert into gb_entries " .
"values ('$username', '$name', '$gender', '$dob', '$email')";
$result = @ mysql_query ($insert, $connection)
or showerror();
mysql_close($connection)
or showerror();
}

// Return an array of database entries that contain $name anad $email
function getEntries($username,$name,$gender,$dob,$email) {
// Sanitise user input to prevent SQL injection attacks
$username = mysql_escape_string($username);
$name = mysql_escape_string($name);
$gender = mysql_escape_string($gender);
$dob = mysql_escape_string($dob);
$email = mysql_escape_string($email);


// Open connection and select database
$connection = mysql_open();

// Construct query
$query =
"select username, name, gender, dob, email from gb_entries where 0=0 ";
if (! empty($username)) {
$query .= "AND username LIKE '%$username%' ";
}
if (! empty($name)) {
$query .= "AND name LIKE '%$name%' ";
}
if (! empty($gender)) {
$query .= "AND gender LIKE '%$gender%' ";
}
if (! empty($dob)) {
$query .= "AND dob LIKE '%$dob%' ";
}
if (! empty($email)) {
$query .= "AND email LIKE '%$email%' ";
}


$query .= "ORDER BY id";
// echo $query;

// Execute query
$result = @ mysql_query($query, $connection)
or showerror();

// Transform the result set to an array (for Smarty)
$entries = array();
while ($row = mysql_fetch_array($result)) {
$entries[] = $row;
}

mysql_close($connection)
or showerror();
return $entries;
}

异常是什么意思?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com