doutuoshou8915 2018-07-05 09:00
浏览 39

你如何正确处理php / mysql中的hash / pound / number(#)符号? [重复]

This question already has an answer here:

I have this website where users can enter stable names to compete in games against other members. Usually it's fine as I can just escape or use addslashes to handle apostrophes and other such characters. What I am having an issue with is when users use a hash/pound/number sign in the stable name like the first example below or a bunch of special characters like the second example below...

#a new rising
ΔMi−1 = −αΣn=1NDi[n][Σj∈C{i}Fji[n - 1] + Fexti[[n-1]]

When this goes over as part of a url to a second page and the stable is a appended to the URL to be used as a GET variable to pull details from the database, nothing is returned. I have tried using urlencode, rawurlencode, and percent encoding on the $stable variable as is suggested in other questions on this site but nothing seems to work. Below is a sample of the code that has the issue...

Referring URL --- mydomain.com/stable.php?stable=#a new rising&season=59

Code for stable.php...

$stable = addslashes($_GET["stable"]);
$season = $_GET['season'];

echo $stable;

$sql = "SELECT total, wins, loss, ties FROM History_Stables WHERE stable = '$stable' AND season = '$season'";
$res = $link->query($sql);
$arr = $res->fetch_array();

$pts = $arr[total];
$w = $arr[wins];
$l = $arr[loss];
$t = $arr[ties];

And so on. What exactly am I missing here to get the hash/pound/number sign to be properly encoded as %23?

</div>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 对于相关问题的求解与代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
    • ¥15 保护模式-系统加载-段寄存器
    • ¥15 电脑桌面设定一个区域禁止鼠标操作
    • ¥15 求NPF226060磁芯的详细资料