Problema stergere din database dupa coloana cu data
Scris: Vin Mar 30, 2012
Culmea, pana acum ceva timp mergea bine.
Table struct:
Inregistreaza in database username, ip, time(h:i:s)
cand dau refresh la pagina,
Apare mesajul. Dar daca mai dau un refresh se sterge din database recordul respectiv.
Daca e nevoie postez mai mai mult din cod. Am considerat ca ar fi mai ok sa nu "incarc" atat de mult postul cu lucruri nu atat de importante problemei.
Cod: Selectaţi tot
$current_time = date("H:i:s");
Cod: Selectaţi tot
$vote_register = mysql_query("INSERT INTO vote (username,ip,time) VALUES ('$_POST[username]','$_SERVER[REMOTE_ADDR]','$current_time')");
Cod: Selectaţi tot
//DELETE FROM DATABASE EVERY 7 HOURS
$today = date("H:i:s", strtotime("-7 hours"));
mysql_query("DELETE FROM vote WHERE time <= '$today'");
Cod: Selectaţi tot
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Database: `uberdb`
--
-- --------------------------------------------------------
--
-- Table structure for table `vote`
--
CREATE TABLE IF NOT EXISTS `vote` (
`username` text NOT NULL,
`ip` text NOT NULL,
`time` text NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Dumping data for table `vote`
--
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
cand dau refresh la pagina,
Cod: Selectaţi tot
$vote_ip_check = mysql_query("SELECT * FROM vote WHERE ip='$_SERVER[REMOTE_ADDR]'"); //check vote ip
Cod: Selectaţi tot
if (isset($_POST['submit']) == false) {
if (mysql_num_rows($vote_ip_check) == '1') {
echo "<div class='ferror red'>You've already voted. The vote - reward system will re-appear automatically 7 hours after you previously voted.</div>";
}
Daca e nevoie postez mai mai mult din cod. Am considerat ca ar fi mai ok sa nu "incarc" atat de mult postul cu lucruri nu atat de importante problemei.