“Unknown column in 'field list'”, but column does exist

后端 未结 9 1376
既然无缘
既然无缘 2020-12-06 04:41
DROP TABLE IF EXISTS `transactions`;
CREATE TABLE `transactions` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `purchase_date` datetime DEFAULT NULL,
  PRIMAR         


        
9条回答
  •  自闭症患者
    2020-12-06 05:32

    I have had the same issue this morning and I didn't find my answer. But I found my problem when I changed the single quotes around my query to double quotes. Something so small and an oversight can cause a real headache.

    Unknown column x in "field list" - Code below wrapped in single quotes - Non working.

        $likepost='INSERT INTO reaction(reaction_num,userreaction_id,timereacted,
        streamitem_id,comment_posted_on) 
        VALUES ($reaction,$target,NOW(),$streamid,$comment_id)';
    

    Code below wrapped in double quotes. working

        $likepost="INSERT INTO reaction(reaction_num,userreaction_id,timereacted,
        streamitem_id,comment_posted_on) 
        VALUES ($reaction,$target,NOW(),$streamid,$comment_id)";
    

提交回复
热议问题