douzhan1935 2013-06-27 15:07
浏览 67
已采纳

concat两次写入数据

Here is my query:

mysql_query ("UPDATE p_candidate SET  `med_comt` = CONCAT_WS(`med_comt`,' ','$_POST[med_comt]') where `candidate_id` = '$_POST[candidate_id]'");

what I am trying to do is use concat so that the new comments are added to the database without overwriting existing comments.

The new comments are not being separated by a space and the new comments get written twice. for example if the existing comment is 'this is a test' and the new comment is 'another one!'

the new data looks like this

this is a testanother one!another one!

what I want is :

this is a test another one!

It would be better if I could get the new comment on a new line like this:

this is a test

another one!

Thanks

  • 写回答

2条回答 默认 最新

  • dqwh0109 2013-06-27 15:10
    关注

    You're using CONCAT_WS as if it were CONCAT. CONCAT_WS works differently. Your first argument should be the SEPARATOR, and your remaining arguments are the values which get split via the SEPARATOR.

    mysql_query ("UPDATE p_candidate SET  `med_comt` = CONCAT_WS(' ', `med_comt`, '$_POST[med_comt]') where `candidate_id` = '$_POST[candidate_id]'");
    

    PS: Please sanitize or prepare your data.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭