2013-03-09 35 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()之前。