如何转义URL中的特殊字符

时间:2015-09-28 13:35:50

标签: php mysql

我对使用字符串的查询感到困惑,其中包含一些特殊字符,如& %$#未经过验证。我已尝试使用urlencode, htmlentities, htmlspecialchars, mysql_real_escape_string,但没有使用此字符串打开任何内容。

通过这种方式我插入数据库:

$name = @$_POST["name"];    
$query = mysql_query("INSERT INTO article SET
                           name='$name',
                           description='$description',
                           html='$html' ");

***From Form*** - <input type="text" name="name">

和Regex:

RewriteRule ^article/([^/\*]+)/?$ /index.php?page=article&name=$1 [L]

如果我使用$name = htmlentities or htmlspecialchars(@$_POST["name"]);

使用例如查询字符串 - Article&amp; number1

在数据库中插入并编码为Article &amp;number1

0 个答案:

没有答案