0

I keep getting this error when I try to explode the array by a comma, How to fix this error can anyone help me ???

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 ??
1

2 Answers 2

1

This is a NOTICE (not an error!) - you're trying to print an array as if it was a string. Use print_r or var_dump instead of echo:

print_r($friendArray_explode);
Sign up to request clarification or add additional context in comments.

Comments

0

this is because you are trying to pinrt an array as it was a string only using echo. For arrays you can use both print_r or var_dump

I would also sugeest you to stop using mysql_ api since they are depecrated, please switch to PDO or mysqli

Furthermore you are ready to mysql injection. there is a nice tutorial here which explain you everything about that -> How can I prevent SQL injection in PHP?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.