gpt4 book ai didi

mysql - Ruby #{} 插入换行符

转载 作者:行者123 更新时间:2023-11-29 07:54:02 25 4
gpt4 key购买 nike

我在 Ruby 中有一个带有两个变量的字符串:

INSERT INTO nodes (node, author) VALUES (#{line}, #{author})

但是 Ruby 在 #{line} 之后抛出换行符,即

...... VALUES(xxxxxxx
, asdds)

是的,我知道注入(inject)漏洞之类的,但这只是我在我的开发机器上运行的具有良好数据的东西。我不会现场这样做。

最佳答案

听起来像 lineauthor 有前导/尾随空格。尝试:

"... VALUES (#{line.strip}, #{author.strip})"

关于mysql - Ruby #{} 插入换行符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25625587/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com