douji1999 2012-12-13 05:31
浏览 32
已采纳

php insert语句错误

i had a query in mysql for just inserting some data the query is

 $insert_query_pur  = "INSERT INTO `dbname`.`tblname` (`USER_NAME`,`PURCHASE_TYPE`,`PURCHASE_KEY`, `SUBSCRIPTION_ID`,`PURCHASE_DATE`,`NO_OF_ISSUE`,`MAGAZINE_ID`,`AppsCode`,`PROCESS_STATUS`,`User_price`,`Publisher_price`, `Publisher_price_inr`) VALUES ('$USER_NAME','$PURCHASE_TYPE','$PURCHASE_KEY','$SUBSCRIPTION_ID','$PURCHASE_DATE','$NO_OF_ISSUE','$MAGAZINE_ID','$AppsCode','$PROCESS_STATUS','$User_price','$Publisher_price','$Publisher_price_inr')";

but when i excecute this query i got an error

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /var/www/thewinkstore.com/magsonwink/modules/admin/support/classes/support_manage.class.php on line 685

i can't find what is the issue. please help me

  • 写回答

1条回答 默认 最新

  • dousong4777 2012-12-13 05:46
    关注

    Don't put all in one line, in situations like these, you might loose the overview too fast.

    The recommendation is that you make use of prepared statements for such insert queries so that you do not need to built the SQL string on your own. This is explained in the PHP manual.

    For an interim improvement, you might want to first of all distribute the string over multiple lines:

    $insert_query_pur  = "
    INSERT INTO `dbname`.`tblname` 
        (
            `USER_NAME`,        `PURCHASE_TYPE`,   `PURCHASE_KEY`, 
            `SUBSCRIPTION_ID`,  `PURCHASE_DATE`,   `NO_OF_ISSUE`,
            `MAGAZINE_ID`,      `AppsCode`,        `PROCESS_STATUS`,
            `User_price`,       `Publisher_price`, `Publisher_price_inr`
        ) 
        VALUES 
        (
            '$USER_NAME',       '$PURCHASE_TYPE',   '$PURCHASE_KEY',
            '$SUBSCRIPTION_ID', '$PURCHASE_DATE',   '$NO_OF_ISSUE',
            '$MAGAZINE_ID',     '$AppsCode',        '$PROCESS_STATUS',
            '$User_price',      '$Publisher_price', '$Publisher_price_inr'
        )
    ";
    

    Whitespace and indentation is your friend. I hope this helps even if it does not solve your concrete issue.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)