我正在创建一个朋友请求页面,它需要将朋友请求作为一个数组,而不是用逗号分隔每个用户名。
我不知道使用内爆或爆炸我确实使用了两者但没有一个给我我想要的结果
当我按下 accpet 按钮时,我收到此错误
警告:implode():在第 59 行 C:\wamp\www\Unnamed Site 2\resources\friend_requests.php 中传递的参数无效
谁能帮我 ???
朋友请求.php
<?php
session_start();
if($sessionlogin = isset($_SESSION['login']))
{
$login = ($_SESSION['login']);
$userid = ($_SESSION['user_id']);
$login_user = ($_SESSION['username']);
$fname = ($_SESSION['first_name']);
$lname = ($_SESSION['last_name']);
$sessionaddres =($_SESSION['address']);
// require_once('header.php');
require_once('for members/scripts/connect.php');
//find friend request
$findrequests = mysql_query("SELECT * FROM friend_requests WHERE user_from = '$login_user'") or die(mysql_error());
$numrows = mysql_num_rows($findrequests);
if($numrows == 0)
{
echo "YOU HAVE no friend Requests at this time";
$user_from = "";
}
else
{
while($get_row = mysql_fetch_assoc($findrequests))
{
$id = $get_row['id'];
$user_to = $get_row['user_from'];
$user_from = $get_row['user_to'];
echo '' . $user_from . ' wants to be friend' . '<br />';
//var_dump($user_from);
//var_dump($user_to);
//echo "your user_to is '$user_to'";
//echo "your user_from is '$user_from'";
?>
<?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 = implode(",", $friend_array);
$friend_array_count = count($friendArray_explode);
//select the friend array row from the user who sent the friend request
$get_friend_check_friend = mysql_query("SELECT friend_array FROM user WHERE user_name = '$user_from'") or die(mysql_error());
$get_friend_row_friend = mysql_fetch_assoc($get_friend_check_friend);
$friend_array_friend = $get_friend_row_friend['friend_array'];
$friendArray_explode_friend = implode(",", $friend_array_friend);
$friend_array_count_friend = count($friendArray_explode_friend);
if($friend_array == "")
{
$friendArray_count = count(NULL);
}
//var_dump($friendArray_count);
if($friend_array_friend == "")
{
$friendArray_count_friend = count(NULL);
}
if (@$friendArray_count == NULL)
{
$add_friend_query = mysql_query("UPDATE user SET friend_array = CONCAT(friend_array, '$user_from') WHERE user_name = '$login_user'");
}
if(@$friendArray_count_friend == NULL)
{
$add_friend_query = mysql_query("UPDATE user SET friend_array = CONCAT(friend_array, '$user_to') WHERE user_name = '$user_from'");
}
/*
if(@$friendArray_count >= 1)
{
$add_friend_query = mysql_query("UPDATE user SET friend_array = CONCAT(friend_array, ',$user_from') WHERE user_name = '$login_user'");
}
/*
if(@$friendArray_count_friend >= 1)
{
$add_friend_query = mysql_query("UPDATE user SET friend_array = CONCAT(friend_array, ',$user_to') WHERE user_name = '$user_from'");
}
*/
// for delete request
$delete_request = mysql_query("DELETE FROM friend_requests WHERE user_to = '$user_to' && user_from = '$user_from'") or die(mysql_error());
echo "YOU are now friends!!";
//header("Location: friend_requests.php");
}
if(isset($_POST['ignorerequest'.$user_from]))
{
$ignore_request = mysql_query("DELETE FROM friend_requests WHERE user_to = '$user_to' && user_from = '$user_from'") or die(mysql_error());
echo "Request ignored !!";
header("Location: friend_requests.php");
}
?><br />
<br />
<br />
<br />
<br />
<form action="friend_requests.php" method="post">
<input type="submit" name="acceptrequest<?php echo $user_from; ?>" value="Accept">
<input type="submit" name="ignorerequest<?php echo $user_from; ?>" value="Ignor">
</form>
<?php
}
}
}
?>