php - 读取斜线输入崩溃

标签 php mysql input crash

将输入保存到数据库时出现问题。

我将字符串另存为:

mysql_real_escape_string($my_string)

然后,我阅读并使用以下命令将字符串放置到输入中:
stripslashes($my_string)

关键是,如果我在字符串中设置双斜杠,则输入将崩溃,如下所示:
<input maxlength = "150" type="text" name = "my_string12" value = "hello "this is" a test"  class="input-medium"/>

谢谢。

最佳答案

如果将值作为PHP变量,则必须对其进行修剪..

使用修剪功能:

$str = 'hello "this is" a test';
echo trim($str, '"'); // hello this is a test

保罗在here回答

关于php - 读取斜线输入崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16373648/

相关文章:

php和mysql foreach只显示第一条记录四次

javascript - 如何使用 NodeJS 将 MySQL 中的数据显示为 HTML 页面

css - 使用 Material 在 Angular2 中实现复选框

javascript - Android WebView HTML 输入按键不会触发

php - 使用 Symfony2 处理主从 (MySQL) 复制延迟

php - 在 PHP 中使用命名空间中的静态函数作为回调

php - 如何将 session 添加到我的表单中?

php - 尝试从 MySQL 数据库中调用 longblob 信息以进行文件输入控制

php - 在 mysqli 中存储和迭代查询结果

PHP如何将查询字符串分隔成变量