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 8562519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:44:50+00:00 2026-06-11T16:44:50+00:00

Here is what I wanna do: User can comment up to five times a

  • 0

Here is what I wanna do: User can comment up to five times a day (in code I use 60 seconds to see the result quicker).
However I seem to make a wrong comparison, because right now it always gives me back true. So even if the counter is above 5, it still counts up instead of stopping there (for 60 seconds).
Any input is appreciated. Down below is the code I use.

<?php
$DB_HostName = "";
$DB_Name = "";
$DB_User = "";
$DB_Pass = "";
$DB_Table = "";

$name = mysql_escape_string($_GET['name']);
set_time_limit(0);

$con = mysql_connect($DB_HostName,$DB_User,$DB_Pass) or die (mysql_error()); 
mysql_select_db($DB_Name,$con) or die(mysql_error()); 

 if ($name[CommentCounterReset] === 5) //or if ("CommentCounterReset === 5 WHERE Name = $name)? {
   echo "You already wrote five comments.";
   set_time_limit(60);  
   $sql = "UPDATE table SET CommentCounterReset = CommentCounterReset-5 WHERE Name = '$name'";
}  else {
 $sql = "UPDATE table SET CommentCounterReset = CommentCounterReset+1 WHERE Name = '$name'";
        echo "Comment accepted.";

 }

$res = mysql_query($sql,$con) or die(mysql_error());

   mysql_close($con);
if ($res) {
}else{
}// end else
?>
  • 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-11T16:44:51+00:00Added an answer on June 11, 2026 at 4:44 pm

    It looks like you are trying to run the query after a wait time with this command:

     set_time_limit(60);  
    

    This makes the maximum run time of your script 60 seconds, but doesn’t actually do anything more. It changes a setting so your script could run a maximum of 1 minute, but doesn’t actually make it run.

    You could do it with sleep but you shouldn’t If you want to do it for a day, that means your script would run for a day (it can, sleep doesn’t “count” as it is a system call).

    Better write a certain time to your database and check against that. If the user wants to comment you check

    Check if the user has 5 comments.

    1. Yes? check the time
      1.if it is in the past, post the comment and reset the counter.

      1. if it is in the future, don’t post the comment.
    2. No? increase the counter and post the comment
      1. did you increase it to 5? then set the date to +60 seconds (or +1 day).
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If you wanna see the code Im having problem with, here is the link:
i wanna do a single selection in my table view here is my code
Here is the code: create table `team`.`User`( `UserID` bigint NOT NULL AUTO_INCREMENT , `Username`
I wanna make option edit product when user login. Here is the link when
Here I've a controller with 4 actions and i wanna apply application layout (
I'm new here. I'm developing some Asp.Net applications and i wanna test them on
Well, here is what I wanna do: I have a text field and a
Here's my code in the <head></head> : <link rel=stylesheet href=http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css /> <script type=text/javascript src=http://code.jquery.com/jquery-1.7.1.min.js></script>
Here is the code in a function I'm trying to revise. This example works
I have a tableView where the user can add contacts to. These contacts get

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.