mysql语法错误插入小数,时间戳与php
我收到错误:
您的 SQL 语法有错误;检查手册 与您的 MySQL 服务器版本相对应,以便使用正确的语法 第 1 行“10”、“16:39:02”、“292.35”)' 附近
这是我在 php 中运行的查询:
mysql_query("INSERT INTO `copper`
(`month`, `time`, `price`)
VALUES
('$month', '$time', '$price')") or die(mysql_error());
这是一个文字示例:
INSERT INTO `table`
(`month`, `time`, `price`)
VALUES
('10', '16:39:02', '292.35')
这是我的表设置
Im getting the error:
You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use
near '10', '16:39:02', '292.35')' at line 1
this is the query im running in php:
mysql_query("INSERT INTO `copper`
(`month`, `time`, `price`)
VALUES
('$month', '$time', '$price')") or die(mysql_error());
Here is a literal example:
INSERT INTO `table`
(`month`, `time`, `price`)
VALUES
('10', '16:39:02', '292.35')
this is my table setup
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这应该像您发布的那样工作,因此这里有一些疯狂的猜测:
您确定
$month
不包含'
吗?您确定这些引用确实是正确的吗?即不是当今文字处理程序中出现的异国情调的东西? (您是从网络/pdf/doc 复制并粘贴此内容吗?)
否则,会丢失查询中的换行符,这应该不重要,但您永远不知道。
This should work as you posted it, so here's a few wild guesses:
Are you sure
$month
doesn't contain a'
?Are you sure those are actually the right kind of quotes? i.e. not the exotic stuff that comes out of word processors these days? (did you copy&paste this from the web / pdf / doc?)
Otherwise, lose the newlines within the query, shouldn't matter but you never know.
回显您的实际查询,以便您可以看到生成的内容。
echo out your actual query so you can see what is generated.