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 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误
  • ¥15 (关键词-阻抗匹配,HFSS,RFID标签天线)
  • ¥15 机器人轨迹规划相关问题
  • ¥15 word样式右侧翻页键消失