将 PHP 中的 MYSQL 调用格式化为 TRIM
我在 PHP 中运行以下命令时遇到困难:
$con = mysql_connect("host", "username", "password") or die ("Unable to connect to server");
mysql_select_db("database") or die ("Unable to select database");
$sql = "UPDATE `table` SET `column` = TRIM(BOTH '"' FROM `column`)";
mysql_query($sql);
echo "quotation mark removed";
mysql_close($con);
这个问题与我认为的语法有关。特别是 BOTH '"' FROM
部分。我怎样才能编写这个 $sql 调用以便 PHP 能够理解它?
这是我的尝试 BOTH '"."""."'来自
I am having difficulty running the following command in PHP:
$con = mysql_connect("host", "username", "password") or die ("Unable to connect to server");
mysql_select_db("database") or die ("Unable to select database");
$sql = "UPDATE `table` SET `column` = TRIM(BOTH '"' FROM `column`)";
mysql_query($sql);
echo "quotation mark removed";
mysql_close($con);
The issue has to do with the syntax I believe. Specifically the BOTH '"' FROM
portion. How can I write this $sql call so that it will be understood by PHP?
This was my attempt BOTH '"."""."' FROM
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要转义双引号(因为您将其用作字符串分隔符),例如:
You need to escape double quote (since you use it as a string delimiter), like: