-1

I am new to PHP and don't have much knowledge so that's why I'm asking here. My problem is that the following code allows my site members to give points to other members, but it only allows it one time, so I want it to give points once per day. What things do I need to make it possible?
Here is the code:

// users can not give 2 x points
$repeat = mysql_query("SELECT userid FROM {$TABLE_PREFIX}reputation WHERE userid ='$id' AND whoadded=".$CURUSER["uid"]);
if( mysql_num_rows( $repeat) > 0 )
{
    stderr("Hold On","You already gave reputation points to this user!");
    stdfoot();
    exit;
}

Any help will be highly appreciated.

Blaz
  • 1
  • 1
  • 1
    [**Please, don't use `mysql_*` functions in new code**](http://stackoverflow.com/a/14110189/1723893). They are no longer maintained [and are officially deprecated](https://wiki.php.net/rfc/mysql_deprecation). See the [**red box**](http://j.mp/Te9zIL)? Learn about [*prepared statements*](http://j.mp/T9hLWi) instead, and use [PDO](http://php.net/pdo) or [MySQLi](http://php.net/mysqli) - [this article](http://j.mp/QEx8IB) will help you decide which. If you choose PDO, [here is a good tutorial](http://j.mp/PoWehJ). – NullPoiиteя Jan 02 '13 at 14:00
  • You might want to add some structure to your explanation – thumbmunkeys Jan 02 '13 at 14:02
  • add condition to check that entry is of today's date. Means, add date condition to where clause – Bhavik Shah Jan 02 '13 at 14:02
  • 2
    what do you want to get exactly ? – NullPoiиteя Jan 02 '13 at 14:04
  • i want my site member to gave same member points once in a day as above codes allow only once to gave points so what codes i need to add so it wait 24 hours & after that again it allow member to gave points to same member – Blaz Jan 02 '13 at 14:10

1 Answers1

0

What you can do you should create a field for TimeVoted , then make the data type to be datetime then use TIMESTAMPDIFF function , it takes three parameters but first play with it in your mysql query window before you apply it in your script , you will understand how it works and you will be able to solve your problem

Php Hunter
  • 63
  • 1
  • 10
  • 1
    sorry but can you gave me codes coz em nob in php so dont have expersionce to creat such all codes & thanks for reply – Blaz Jan 02 '13 at 15:34
  • 1
    select username from site_user WHERE TIMESTAMPDIFF(MINUTE,dateupdated ,NOW())<1 – Php Hunter Jan 02 '13 at 15:49
  • ok thank you so do i need to run any SQL quary as i found a quary for said matter is `rep_repeat` varchar(10) collate utf8_unicode_ci NOT NULL, – Blaz Jan 02 '13 at 15:57
  • 1
    Yes you have to use an sql query but check on how to use TIMESTAMPDIFF first it will give you right directions – Php Hunter Jan 02 '13 at 16:04