I'm trying to insert some values to my table, but i keep getting the following Notice :
Notice: Array to string conversion in C:\Program Files\wamp\www\process_invitation.php on line 10
Line 10 is the insertion line in the following code :
if ((isset($_POST['inviter'], $_POST['opponent'])) && ($_POST['inviter'] != '' && $_POST['opponent'] != '' )) {
$inviter = $_POST['inviter'];
$opponent = $_POST['opponent'];
$now = time();
if ($mysqli->query("INSERT INTO invitations (inviter_user_id, invited_user_id, time) VALUES ('$inviter','$opponent','$now')")) {
return;
}
}
Have you tried var_dumping $inviter and $opponent to see what datatype they are? Try just casting them to (string) too. Also, it's a good idea to use parameterised queries with mysqli. As it stands, you're leaving yourself wide open to SQL injections.
Print the output of variables & you will know where the problem is:
print_r($inviter);
print_r($opponent);
Make sure to extract value from the array before mysql insertion.