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

  • SEARCH
  • Home
  • 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 7091267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:09:50+00:00 2026-05-28T08:09:50+00:00

i Have a Script for my shop for a game where after they buy

  • 0

i Have a Script for my shop for a game where after they buy something they cant buy anything for 1 week. but i cannot get this script to work. Can Someone Explain to me How to Set up The MySql Database to block the user?

<?php
// Purge records
mysql_query("DELETE FROM ip_table WHERE access_date < DATE_SUB(CURDATE(), INTERVAL 168 HOUR)");

$ip = $_SERVER['REMOTE_ADDR'];
$result = mysql_query("SELECT ip FROM ip_table WHERE ip = '$ip'");
if($result){
  die("TOS: You cannot access this for 1 Week, Security Measure");
} 
else {
  $result = mysql_query("INSERT INTO ip_table (ip, access_date) VALUES ('$ip', NOW())");
  echo "Thank you For your Purchase. you Have been Blocked For 1 Week due to a Security Measure.";
}
?>

All help is appreciated. thanks

  • 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-05-28T08:09:50+00:00Added an answer on May 28, 2026 at 8:09 am

    Don’t check with if ($result), as that will return a valid result resource, even if it has no rows. Therefore, it will always enter the die() block.

    Instead check mysql_num_rows() to see if a row was returned from this query, in addition to testing for FALSE in $result, which indicates an error in the query.

    $result = mysql_query("SELECT ip FROM ip_table WHERE ip = '$ip'");
    if($result && mysql_num_rows($result) > 0){
      die("TOS: You cannot access this for 1 Week, Security Measure");
    } 
    

    Note:

    Though it should not be possible to launch a SQL injection attack from $_SERVER['REMOTE_ADDRESS'], get in the habit of escaping the values in $_SERVER anyway:

    $ip = mysql_real_escape_string($_SERVER['REMOTE_ADDR']); 
    

    Update

    If you haven’t yet figured out how to create this table, here’s the statement which will do it:

    CREATE TABLE ip_table (
      ip VARCHAR(15) NOT NULL,
      access_date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
    );
    

    One issue to consider: Multiple users can appear to your web server as coming from the same originating IP, if they are behind a NAT, a corporate or a school network. You are advised to add some other identifier to the user if you can.

    Basic MySQL connection pattern:

    $conn = mysql_connect("localhost", "someusername", "thepassword");
    if (!$conn) {
      // Error connecting.
    }
    else {
      mysql_select_db("yourDatabaseName");
    }
    // Now you can call mysql_query()...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have script like this : fullscript.sh if [ ! -f /opt/laks/linux-2.6.33.2.tar.bz2 ] then
I have this script that run to fix my menu bar to the browser
I have script called Script.php and tests for it in Tests/Script.php, but when I
I have this script which is used to append: function append_place(type) { var shop_type
I have script that reads remote file content and writes it to local server.
i have script for insert multiple rows : protected static final String INSERT_NAME_LIST1 =
I have script file where a command is stored in a variable First i
I have script which allows to display Bing search results. I can call for
I need to have script.sh , that would create files f1.txt and f2.txt with
i have a script which is for virtual keyboard, i am facing some problem

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.