Erro em um código de update.
Estou com um problema que todas as vezes que tento acessar a página principal dá o seguinte erro "Erro ao alterar usuário"
Abaixo segue o código e o script do banco
meu código é o seguinte:
<?php require_once('Connections/conaxao.php'); ?>
<?php
$ip = $_SERVER["REMOTE_ADDR"]; //Pego o IP
$cont = ("1");
$host = gethostbyaddr("$ip"); //pego o host
$browser = $_SERVER['HTTP_USER_AGENT'];//versão do sistema
$data = date('Y-m-d H:i:s');
$pagina = "(inicial.php)Página princpal";
$sql3 = "insert into acesso_ao_site values('','$ip','".date("Y-m-d H:i:s")."','$browser','$host','$pagina');"; //insiro os dados na tabela
$consulta3 = mysql_query($sql3); //confirmo ação de inserção
$sql = "UPDATE status_acesso SET cont=cont + 1, ip='".$_SERVER["REMOTE_ADDR"]."', data_acesso = '".date('Y-m-d H:i:s')."', host = '".gethostbyaddr("$ip")."' where id_ip = '1'";
$resultado = mysql_query($sql)
or die ("Erro ao alterar usuario.");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="[http://www.w3.org/1999/xhtml">](http://www.w3.org/1999/xhtml)
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<link href="css/estilos.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
h2 {
color: #000066;
}
-->
</style></head>
<body>
<div id="central">
<div id="cabecalho"></div>
<div id="corpo">
<?php
$sql_visita = "SELECT * FROM status_acesso ";
$qrv = mysql_query($sql_visita);
while ($linhas = mysql_fetch_array($qrv)){
?>
<strong>Número de visitas: </strong><?php echo $linhas['cont']; ?>
<?php } ?>
<form action="admin/validacao.php" method="post">
<fieldset>
<legend>Area restrita</legend>
Usuário:
<input type="text" name="usuario" id="txUsuario" maxlength="25" />
Senha:
<input type="password" name="senha" id="txSenha" />
<input type="submit" value="Entrar" />
</form>
</fieldset>
<hr size="1" />
<div id="anuncios">
<?php
$sql = "SELECT * FROM anuncio ORDER BY cod_anuncio DESC";
$qr = mysql_query($sql);
while ($linha = mysql_fetch_array($qr)){
?>
<div id="item_anuncio">
<table width="93%" border="0">
<tr>
<td width="100%" align="center" valign="top"><h2><?php echo ''.substr($linha['titulo'], 0, 20).'';?>
</h2></td>
</tr>
<tr>
<td align="center" valign="top"><div align="justify"><?php echo ''.substr($linha['conteudo'], 0, 250).'';?></div></td>
</tr>
<tr>
<td align="center" valign="top"><strong>Autor:</strong><?php echo $linha['autor'];?></td>
</tr>
</table>
</div>
<?php }?>
</div>
</div>
<div id="rodape"><hr size="1" />
<div align="center">2009 Todos os direitos reservados</div>
</div>
</div>
</body>
</html>
O script do banco é o seguinte:
CREATE TABLE IF NOT EXISTS `acesso_ao_site` (
`cod_ip` int(11) NOT NULL AUTO_INCREMENT,
`ip_acesso` varchar(100) NOT NULL,
`data` datetime NOT NULL,
`sistema` varchar(100) NOT NULL,
`host` varchar(100) NOT NULL,
`pagina` varchar(100) NOT NULL,
PRIMARY KEY (`cod_ip`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=35;
CREATE TABLE IF NOT EXISTS `status_acesso` (
`id_ip` int(11) NOT NULL AUTO_INCREMENT,
`ip` varchar(20) NOT NULL DEFAULT '',
`data_acesso` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`cont` int(11) NOT NULL DEFAULT '0',
`host` varchar(225) DEFAULT NULL,
PRIMARY KEY (`id_ip`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2;Discussão (6)
Carregando comentários...