dongtiao0657 2015-11-20 12:44
浏览 78

试过这个:SQL语法错误 - 无法插入多行

Can not find the problem in this MySQL query. Can't insert rows. Have checked the script many times but can not find out what's wrong.

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 'hashtag1,('hashtag1','751','1','2015-11-20 11:37:48','1448019468'), hashtag2,('hashtag2','751','1' at line 2

My script:

    $hashtags = array();

    preg_match_all("/(#\w+)/", $text, $matches);

    if(!empty($matches[0]) ){

    foreach( $matches[0] as $hashtag ){

    $hashtag = strtolower(str_replace('#', '', $hashtag));

    array_push($hashtags, "('$hashtag','$publi','1','".TM1."','".TM2."')");
    }

    $hashtags = array_unique($hashtags);

    $result = mysqli_query($dcon1,'INSERT INTO w_hashtags(htag,publicat,numbr,tm1,tm2) 
VALUES ('.implode(',', $hashtags).') 
    ON duplicate KEY UPDATE numbr=numbr+1, tm1='.TM1.', tm2='.TM2.'') or die(mysqli_error($dcon1));
  • 写回答

1条回答 默认 最新

  • duannaikuang1301 2015-11-20 14:05
    关注

    At last!

    $result = mysqli_query($dcon1,"INSERT INTO w_hashtags(htag,publicat,numbr,tm1,tm2) 
    VALUES ".implode(',', $hashtags)." 
        ON duplicate KEY UPDATE numbr=numbr+1, tm1='".TM1."', tm2='".TM2."'") or die(mysqli_error($dcon1));
    
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作