Reputation: 5107
I am using the following code to insert one record to a MySQL database:
mysql_select_db($database_conexion, $conexion);
$ipcliente = $_SERVER['REMOTE_ADDR'];
date_default_timezone_set('America/Los_Angeles');
$date = date('Y-m-d H:i:s');
mysql_query("INSERT
INTO tbactividad
(hora,ip,motivo)
VALUES
('$date','$ipcliente','Inicio')") or die(mysql_error());
But the final result is that two records are inserted, the field 'hora' which stores the date-time on each record is not the same, there is a +2 or +1 seconds difference.
Any help is welcome,
COMPLETE CODE:
<?php require_once('Connections/conexion.php');
mysql_select_db($database_conexion, $conexion);
$ipcliente = $_SERVER['REMOTE_ADDR'];
date_default_timezone_set('America/Los_Angeles');
$date = date('Y-m-d H:i:s');
mysql_query("INSERT
INTO tbactividad
(hora,ip,motivo)
VALUES
('$date','$ipcliente','Inicio')") or die(mysql_error());
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Quini-Mex CD JUAREZ</title>
<link href="jquery-mobile/jquery.mobile.theme-1.0.min.css" rel="stylesheet" type="text/css"/>
<link href="jquery-mobile/jquery.mobile.structure-1.0.min.css" rel="stylesheet" type="text/css"/>
<style type="text/css">
body {
background-image: url();
background-repeat: repeat;
}
</style>
<script src="jquery-mobile/jquery-1.6.4.min.js" type="text/javascript"></script>
<script src="jquery-mobile/jquery.mobile-1.0.min.js" type="text/javascript"></script>
</head>
<body>
<div data-role="page" data-theme="a" id="page" >
<div data-role="header">
<h1>Quini-Mex Juárez</h1>
</div>
<div data-role="content">
<p>Bienvenid@s a QUINI-MEX JUAREZ, el nuevo sitio web para sus quinielas de futbol.</p>
<p>Seleccione su opcion para entrar. </p>
<p> </p>
<ul data-role="listview">
<li><a href="nuevo_usuario.php" data-ajax="false">SOY UN USUARIO NUEVO</a></li>
<li><a href="login.php" data-ajax="false">USUARIO YA EXISTENTE</a></li>
</ul>
</div>
<p> </p>
<p> </p>
<div data-role="footer" data-position="fixed">
<h4><img src="imagenes/mex.png" width="35" height="23"> <img src="imagenes/bra.png" width="35" height="23"> <img src="imagenes/cro.png" width="35" height="23"> <img src="imagenes/cmr.png" width="35" height="23"></h4>
</div>
</div>
<div data-role="page" id="page2">
<div data-role="header" data-position="fixed">
<h1>Page Two</h1>
</div>
<div data-role="content">
Content
</div>
<div data-role="footer" data-position="fixed">
<h4>Page Footer</h4>
</div>
</div>
<div data-role="page" id="page3">
<div data-role="header">
<h1>Page Three</h1>
</div>
<div data-role="content">
Content
</div>
<div data-role="footer">
<h4>Page Footer</h4>
</div>
</div>
<div data-role="page" id="page4">
<div data-role="header">
<h1>Page Four</h1>
</div>
<div data-role="content">
Content
</div>
<div data-role="footer">
<h4>Page Footer</h4>
</div>
</div>
</body>
</html>
Upvotes: 1
Views: 74
Reputation: 9635
No problem is seen in your code where as problem can be your page is reloading twice by something hidden reason
.
you can try some given solutions
background-image: url();
Note: I have already commented the this answer. but i am giving this as an answer post so that this question may not be listed in unanswered because OP's problem has been solved as commented below question.
Upvotes: 2