我有这个问题:
insert into t_calls(`uniqueid`, `clid`, `first_answer_calls`, `duration`,
`billsec`, `waitforanswer`, `disposition`, `typecalls`, `calldate`,
`stprefix`, `stsuffix`, `filename`, `amaflags`) values('1395901608.476880',
'+380688XXXXXX', '0', 0, 0, 0, 'CHANUNAVAIL', 1, '2014-03-27 06:26:48','157*', '',
'IN_20140327-062648_+380688XXXXXX_-1_0_0','0001')
我的t_calls表
mysql> explain t_calls;
+--------------------+--------------+------+-----+---------------------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------------+--------------+------+-----+---------------------+-------+
| uniqueid | varchar(32) | NO | PRI | | |
| clid | varchar(80) | NO | MUL | | |
| first_answer_calls | varchar(32) | YES | MUL | NULL | |
| duration | int(11) | NO | | 0 | |
| billsec | int(11) | NO | | 0 | |
| waitforanswer | smallint(3) | NO | MUL | 0 | |
| disposition | varchar(45) | NO | | | |
| amaflags | int(11) | NO | | 0 | |
| typecalls | tinyint(2) | NO | MUL | 0 | |
| calldate | datetime | NO | MUL | 0000-00-00 00:00:00 | |
| stprefix | varchar(10) | YES | MUL | | |
| stsuffix | varchar(32) | YES | MUL | NULL | |
| filename | varchar(254) | YES | | | |
+--------------------+--------------+------+-----+---------------------+-------+
13 rows in set (0.00 sec)
当我通过mysql CLI执行此查询时一切正常,但是当我通过PHP Mysqli尝试它时收到错误:
1054:'字段列表'中的未知列'stsuffix')
我做错了什么?
MySQL服务器版本:5.1.63-0 + squeeze1-log
PHP 5.3.3-7 +使用Suhosin-Patch挤压19
$link= new mysqli($mysql_db, $mysql_user, $mysql_pass,"estprod");
$res=$link->query($query);
$errnum = $link->errno;
$errmsg = $link->error;
if ($errnum==0)
{
echo "Query in file $data inserted.\n";
}
else
{
if (($errnum==1037) or ($errnum==1038) or ($errnum==1040) or ($errnum==1041) or ($errnum==1105))
{
echo ("Error in MySQL server($errnum: $errmsg).");
}elseif (($errnum==1044) or ($errnum==1045) or ($errnum==1053) or ($errnum==1142) or ($errnum==1143))
{
echo ("No GRANT for insert operation($errnum: $errmsg). HELP.");
}elseif (($errnum==1054) or ($errnum==1058) or ($errnum==1064) or ($errnum==1065))
{
echo "Error execute mysql query($errnum: $errmsg). \n";
}elseif (($errnum==1062))
{
echo "Query duplicate.\n";
}else
{
echo "Unknow error: ($errnum) $errmsg\n";
}
}
答案 0 :(得分:0)
使用此代码并检查是否列出了列stsuffix
<?php
$result = mysql_query("SHOW COLUMNS FROM sometable");
if (!$result) {
echo 'Could not run query: ' . mysql_error();
exit;
}
if (mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_assoc($result)) {
print_r($row);
}
}
?>
有时可能会创建字段&#39; stsuffix&#39;在 数据库表中有一些空格,例如&#39; stsuffix&#39;