开发者

Formatting MYSQL call in PHP to TRIM

开发者 https://www.devze.com 2023-03-24 22:05 出处:网络
I am having difficulty running the following command in PHP开发者_开发知识库: $con = mysql_connect(\"host\", \"username\", \"password\") or die (\"Unable to connect to server\");

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


You need to escape double quote (since you use it as a string delimiter), like:

$sql = "UPDATE `table` SET `column` = TRIM(BOTH '\"' FROM `column`)";
0

精彩评论

暂无评论...
验证码 换一张
取 消