【问题标题】:cakephp blog tutorial error whith mysql now()cakephp 博客教程错误与 mysql now()
【发布时间】:2014-04-10 20:06:40
【问题描述】:

我正在尝试食谱中的博客教程

CREATE TABLE posts (
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
title VARCHAR(50),
body TEXT,
created DATETIME DEFAULT NULL,
modified DATETIME DEFAULT NULL
);

但是当我插入他给我的值时

INSERT INTO posts (title,body,created)
VALUES (’The title’, ’This is the post body.’, NOW());
INSERT INTO posts (title,body,created)
VALUES (’A title once again’, ’And the post body follows.’, NOW());
INSERT INTO posts (title,body,created)
VALUES (’Title strikes back’, ’This is really exciting! Not.’, NOW());

我收到此错误消息

#1064 - 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 'title’, ’This is the post body.’, NOW())' at line 2 

【问题讨论】:

    标签: php mysql sql cakephp cookbook


    【解决方案1】:

    正确的格式是

    INSERT INTO posts 
    (
    title,body,created
    )
    VALUES 
    (
    'The title', 'This is the post body.', NOW()
    );
    

    http://sqlfiddle.com/#!2/2796d

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多