问题描述
我有一段时间我认为这是一个非常简单的查询:
它实际上不会在指定的表中插入新记录,但是
不返回错误,实际上它返回1。 (或者说)查询是成功的。
要知道的事情:
1. id字段是自动递增的主键
2.其他查询SELECT,UPDATE和DELETE都没问题
3. INSERT通过phpMyAdmin工作
4.查询生成通过phpMyAdmin并粘贴到我的PHP中无法工作
5.使用或省略引号和反引号无效
这是我的查询:
$ query =" INSERT INTO`columns`
(`id`,`date`,`status`,`title`,`author`,`abstract`, `asker`,
`askeradd`,`question`,`response`)
VALUES(NULL,''" .date(" Ym-d") 。'',''无效'',''$ title'',''1',
''$ abstract'',''$ asker'',''$ askeradd'',''$ question'',''$ response'')" ;;
这是php(尝试生成某种有用的反馈):
if($ res = mysql _query($ query)){
print(''res =''。$ res。"< br> \ n");
print( 错误: 。 mysql_error()。 "<峰; br> \\\
" 。 mysql_errno());
} else {
print(mysql_error()。"< br> \ n" .mysql_errno());
}
这是它的回报:
$ res = 1
错误:BLANK(错误信息会在这里)
0(错误号码)
如果有人可以提出其他尝试,我会非常感激;
我已经尝试了我能想到的一切。
谢谢,
I am having a hell of a time with what I think is a very simple query:
It won''t actually insert a new record into the specified table, but
returns no error, in fact it returns "1" (or true) that the query was
successful.
Things to know:
1. id field is auto-incrementing primary key
2. Other queries SELECT, UPDATE, and DELETE all work no problem
3. INSERT works via phpMyAdmin
4. Query generated by phpMyAdmin and pasted into my PHP doesn''t work
5. Use or omission of quotes and backticks have no effect
Here is my query:
$query = "INSERT INTO `columns`
(`id`, `date`, `status`, `title`, `author`, `abstract`, `asker`,
`askeradd`, `question`, `response`)
VALUES (NULL, ''" . date("Y-m-d") . "'', ''inactive'', ''$title'', ''1'',
''$abstract'', ''$asker'', ''$askeradd'', ''$question'', ''$response'')";
Here is the php (trying to generate some kind of helpful feedback):
if ($res = mysql_query($query)){
print (''$res = '' . $res . "<br>\n");
print ("Error: " . mysql_error() . "<br>\n" . mysql_errno());
} else {
print (mysql_error() . "<br>\n" . mysql_errno());
}
This is what it returns:
$res = 1
Error: BLANK (error message would be here)
0 (error number)
If anyone can suggest other things to try I would really appreciate it;
I have tried everything I can think of.
Thanks,
这篇关于INSERT查询的神秘问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!