2013-04-21 110 views
0

当我尝试用逗号分解数组时,我不断收到此错误,如何解决此错误任何人都可以帮助我?php mysql +注意:数组以字符串转换C

friend_request.php

<?php 

    if(isset($_POST['acceptrequest'.$user_from])) 
    { 
     //select the friend array row from the logged in user 
     $get_friend_check = mysql_query("SELECT friend_array FROM user WHERE user_name = '$login_user'") or die(mysql_error()); 
     $get_friend_row = mysql_fetch_assoc($get_friend_check); 
     $friend_array = $get_friend_row['friend_array']; 
     $friendArray_explode = explode(",", $friend_array); 
     echo $friendArray_explode; 
    } 
    ?> 

The last line of code produce this error how to fix it ?? 
+3

http://imgs.xkcd.com/comics/exploits_of_a_mom.png – imulsion 2013-04-21 09:27:06

回答

1

这是一个注意(不是一个错误!) - 你想打印一个数组,如果它是一个字符串。使用print_rvar_dump代替echo

print_r($friendArray_explode); 
0

这是因为你正试图pinrt一个数组,因为它是唯一使用echo的字符串。对于数组,你可以同时使用print_rvar_dump

我也sugeest您停止使用mysql_ API,因为它们depecrated,请切换到PDOmysqli

而且你准备mysql injection。有一个很好的教程,这里解释你的一切 - >How can I prevent SQL injection in PHP?

+0

也我的评论 - xD – imulsion 2013-04-21 09:53:05