Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/278.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/58.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php URL编码问题_Php_Mysql - Fatal编程技术网

Php URL编码问题

Php URL编码问题,php,mysql,Php,Mysql,我编写这个简单的脚本来记录广告/链接点击,并在长URL或带有特殊字符的URL时遇到问题,例如:?=etc,它中断重定向并仅加载域部分 所以我正在努力让urlencode工作。到目前为止,我已经尝试了两种方法,但都不起作用。 我知道mysql\u查询已经过时,仍在学习中 当前代码: <?php require('config.php'); // Update Ad Pull/Display count $AdID= mysql_real_escape_string($_GE

我编写这个简单的脚本来记录广告/链接点击,并在长URL或带有特殊字符的URL时遇到问题,例如:?=etc,它中断重定向并仅加载域部分

所以我正在努力让urlencode工作。到目前为止,我已经尝试了两种方法,但都不起作用。 我知道mysql\u查询已经过时,仍在学习中

当前代码:

<?php
require('config.php');

    // Update Ad Pull/Display count
    $AdID= mysql_real_escape_string($_GET['AdID']);
    $UpdateADHitDisplay = mysql_query("UPDATE ads SET clicks = clicks +1 WHERE ID = '$AdID'");

    // Get Redirection Inforamtion
    $RedirectURL = $_GET['RedirectURL'];
    //$FixedURL = urlencode($RedirectURL); // this way didn't work
        function url_encode($RedirectURL){ // then tried to use it as a function and no go either.
         return urlencode(utf8_encode($RedirectURL));
     }
    header("Location: $RedirectURL");

?>
传递的链接示例:
http://yourdomain.com/clickcounter.php?AdID=43&RedirectURL=http://stackoverflow.com


故障链接示例:
https://www.demoexample.com/index.aspx?d=111&prog_id=tttt

请给出无法重定向的URL的确切示例。(我注意到,虽然您正在定义一个函数
url\u encode()
,但您实际上并没有调用该函数)在重定向之前,不必对url进行url编码()。在这两者之间,我认为第一个是有问题的,而不是第二个,如果其中一个是有问题的。我不理解您的意思-我的意思是,我不认为这两个都会引起任何问题
$\u GET
参数将自动
urldecode()
ed。您发布的第二个url
demoexample.com
重定向url
的内容?
•Table : ads 
•Row : clicks