简体   繁体   English

将数据传递给查询构建器

[英]passing data to query builder

I am using PHP and MySQL. 我正在使用PHP和MySQL。

I had a form text field where in 我有一个表单文本字段,其中

<input type='text' name ='key' id='key' value = 'property5 = mobile'>

I try to pass this value to mysql query builder just appending this value to where clause, but it does not work because the value part does not have quotes around it. 我试图将此值传递给mysql查询生成器,只是将此值附加到where子句中,但是它不起作用,因为值部分周围没有引号。 How do I fix this? 我该如何解决?

I don't know what you are doing... but I am guessing by your post that you are trying to escape your data. 我不知道您在做什么...但是我在您的帖子中猜测您正在尝试转义数据。

To do this, use the mysql_real_escape_string() function. 为此,请使用mysql_real_escape_string()函数。 Documentation can be found at http://www.php.net/manual/en/function.mysql-real-escape-string.php . 可以在http://www.php.net/manual/en/function.mysql-real-escape-string.php上找到文档。

This will take your string and add all the appropriate escaping automatically. 这将使用您的字符串并自动添加所有适当的转义。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM