Jump to content

Delete * From (Timestamp)


Twist3d

Recommended Posts

Hello.

Well im trying to make like a voting system, where you can only vote for 1 thing every 12 hours.

Mate of mine suggested IP logging.

So i made a script where it Logs the IP and Gives it a random timestamp (Haven't added that, but i just use Insert on PHPMyAdmin).

What this does, is the code searchs for your IP in the database, if it shows your IP is in there, it won't let you into the site. If it doesn't, then your aloud in. But what im trying to do is make the code Delete your IP from the Database, so you are free to vote again. Im trying to get this to work every 20 seconds as a Test, but it will be doing it every 12 hours.

 

But the code works, atleast i think it does? But it doesn't delete anything. But it doesn't give me an error log either.

 

$query = "DELETE * FROM iplog WHERE UNIX_TIMESTAMP(Timestamp) < ' . (time() - 10)";
mysql_query($query);
?>

 

The Timestamp field is just a Default Timestamp.

Any help?

Link to comment
https://forums.phpfreaks.com/topic/185884-delete-from-timestamp/
Share on other sites

your syntax is incorrect for DELETE .. check the manual: http://dev.mysql.com/doc/refman/5.0/en/delete.html

 

would be something more along the lines of:

 

$query = "DELETE FROM iplog WHERE UNIX_TIMESTAMP(Timestamp) < ' . (time() - 10)";

 

that random ' will also throw an error.  add trigger_error() to your query:

 

mysql_query($query) or trigger_error (mysql_error());

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.