2013-03-09 36 views
0

我有一个URL数组,我在PHP端迭代后保存在数据库中。 我使用Ajax发送数组并使用PHP进行保存。通过PHP保存URL在MySql数据库中失败

数据通过Ajax

linksString=http://localhost/phpmyadmin/index.php?db=testdb&token=42d0dde57469a9aa4b6a2f7e0741, 
http://localhost/phpmyadmin/index.php?db=testdb&token=98604a9aa4b6a2f7e0741, 
http://localhost/phpmyadmin/index.php?db=testdb&token=9864dde57469a9aa4b6a2f7e0741, 
http://localhost/phpmyadmin/index.php?db=testdb&token=986042d0dde57469a9aa4b6a2f7e0741, 
http://localhost/phpmyadmin/index.php?db=testdb&token=986042d0dde57469a9a23&q=save 

没有得到在$ linksPieces所有值,获得只有一个值

,但我没有得到这个在PHP侧的所有串发送;只获取第一个逗号(,)之前的第一个子字符串。 即

http://localhost/phpmyadmin/index.php?db=testdb&token=42d0dde57469a9aa4b6a2f7e0741 

PHP

$linksPieces = array(); 
$links = $_POST['linksString']; 
$linksPieces = explode(",", $links); 
foreach($linksPieces as $link) 
{ 
    //operation 
} 

我需要在阵列中的所有字符串在PHP端。

如果我发送这些类型的网址没有任何=然后工作正常。

http://in.yahoo.com/ 

http://www.hotmail.com/ 

http://www.google.com/ 

http://www.blah.com/ 

http://www.blah1.com/ 
+0

什么工作不正常? , – Sedz 2013-03-09 10:54:27

+2

在PHP – Sedz 2013-03-09 10:58:09

+0

中尝试使用从JS encodeURIComponent(str)和urldecode($ _ POST ['linksString'])发送它时您是否检查过$'links'中的值($ _POST中的IE)你打电话爆炸之前? – ethrbunny 2013-03-09 13:31:20

回答

1

您可以尝试使用JavaScript中使用encodeURIComponent()此字符串之前在PHP中发送此字符串,并使用urldecode()之前。