Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9223387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:03:58+00:00 2026-06-18T04:03:58+00:00

Would some one please help me, i have a block user script. Basically everything

  • 0

Would some one please help me, i have a block user script. Basically everything is working ok.

When the user clicks block on the other users profile, this echos the user id, and inserts the user_id and other profile_id into the database and sets the column ‘blocked’ from ‘0’ to ‘1’.

the user who is logged in can now not see the other user they have blocked, however the other the user they blocked can still see their profile.

the way my database works is that it needs both sets id in both columns like so:

user_id   |   blocked_id  |  blocked

   1               2            1
   2               1            1

In order for both users to not see each other and both be blocked i need to try insert the two id’s twice almost.

It’s kind of like duplicating the values inserted into the table to create the same result twice but only the other way around in the table columns.

so at the moment i have:

$sql = mysql_query("INSERT INTO ptb_block_user (user_id, blocked_id) VALUES (".$_SESSION['user_id'].", ".$user_to_id.")");

and i would need to insert these values twice but the opposite way round so it looks like the table above.

I hope im making myself clear, does anyone know how i could do this?

Thanks.

<?php

session_start();

    confirm_logged_in();

    if (isset ($_GET['to'])) {
    $user_to_id = $_GET['to'];


}


if (!isset($_GET['to']))
    exit('No user specified.');

$user_id = $_GET['to'];




$sql = mysql_query("INSERT INTO ptb_block_user (user_id, blocked_id) VALUES (".$_SESSION['user_id'].", ".$user_to_id.")");


$result1 = mysql_query("UPDATE ptb_block_user SET blocked='1' WHERE user_id=".$_SESSION['user_id']."") 
or die(mysql_error());





if($result1) 
{ 
$_SESSION['message2']="<div class=\"infobox-profile\"><strong>User Blocked</strong> - This user has successfully been blocked. You will no longer be abler to interact with each other's profiles.</div><div class=\"infobox-close\"></div>"; 
header("Location: {$_SERVER['HTTP_REFERER']}");
} 
else 
if($result2) 
{ 
$_SESSION['message2']="<div class=\"infobox-favourites\"><strong>User Unblocked</strong> - This user has successfully been unblocked. You can now interact with each other's profiles.</div><div class=\"infobox-close4\"></div>"; 
header("Location: {$_SERVER['HTTP_REFERER']}");

}
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T04:03:59+00:00Added an answer on June 18, 2026 at 4:03 am

    Your question is not entirely clear to me, but it seems like you’re asking how to insert both values with the same query. VALUES can take multiple tuples:

    INSERT INTO ptb_block_user (user_id, blocked_id, blocked) VALUES
        (".$_SESSION['user_id'].", ".$user_to_id.", 1),
        (".$user_to_id.", ".$_SESSION['user_id'].", 1)
    

    Your code is highly vulnerable to mysql injection, and you should not use ext/mysql:

    http://www.php.net/manual/en/faq.databases.php#faq.databases.mysql.deprecated

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have got one issue. Can some one please help me to resolve this?
I would appreciate some help on creating the proper SQL to retrieve only one
I seem to have hit a wall here and would appreciate some help from
I have an xml being returned by an extension method. Can some please help
I need some help with this. Basically I have the following code which I
Can someone please shed some light on how I would get this to work:
My website's functionality would resemble with VWORKER.COM, ELANCE.COM, ODESK.COM etc. Can some one suggest
I would like to get some feedback on what is one of my first
I have hit a road block on this and would highly appreciate if someone
Please have a look at the above screen shot, I would want to center

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.