Foros del Web » Programando para Internet » PHP »

Contador de visitas para post

Estas en el tema de Contador de visitas para post en el foro de PHP en Foros del Web. Hola tengo una consulta, tengo este script es para saber las visitas a los post pero no he logrado que funcione : Código PHP:   $updateSQL  ...
  #1 (permalink)  
Antiguo 09/12/2012, 09:18
 
Fecha de Ingreso: marzo-2011
Mensajes: 115
Antigüedad: 13 años, 1 mes
Puntos: 0
Contador de visitas para post

Hola tengo una consulta, tengo este script es para saber las visitas a los post pero no he logrado que funcione :

Código PHP:
  $updateSQL = ("UPDATE formulario_clasificados SET visitas=visitas+1 WHERE id_rubro=%s"); 
este script lo pongo donde se ve el post entero..

asi es como esta la Base de Datos

Código SQL:
Ver original
  1. CREATE TABLE IF NOT EXISTS `formulario` (
  2.   `id_rubro` INT(11) NOT NULL AUTO_INCREMENT,
  3.   `Titulo` VARCHAR(255) CHARACTER SET latin1 DEFAULT NULL,
  4.   `Descripcion` VARCHAR(255) CHARACTER SET latin1 DEFAULT NULL,
  5.   `email` VARCHAR(255) CHARACTER SET latin1 DEFAULT NULL,
  6.   `Imagen` VARCHAR(255) COLLATE utf8_spanish_ci DEFAULT NULL,
  7.   `fecha` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
  8.   `visitas` INT(11) DEFAULT NULL,
  9.   PRIMARY KEY (`id_rubro`)
  10. ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci AUTO_INCREMENT=35 ;

si me pueden ayudar muy agradecido
  #2 (permalink)  
Antiguo 09/12/2012, 09:38
Avatar de David
Moderador
 
Fecha de Ingreso: abril-2005
Ubicación: In this planet
Mensajes: 15.720
Antigüedad: 19 años
Puntos: 839
Respuesta: Contador de visitas para post

En el update pones formulario_clasificados, pero en la estructura de la tabla solo dice formulario. ¿Cuál es el nombre real?
__________________
Por favor, antes de preguntar, revisa la Guía para realizar preguntas.
  #3 (permalink)  
Antiguo 09/12/2012, 09:44
 
Fecha de Ingreso: marzo-2011
Mensajes: 115
Antigüedad: 13 años, 1 mes
Puntos: 0
Respuesta: Contador de visitas para post

Cita:
Iniciado por David Ver Mensaje
En el update pones formulario_clasificados, pero en la estructura de la tabla solo dice formulario. ¿Cuál es el nombre real?
perdon es formulario_clasificados..
  #4 (permalink)  
Antiguo 09/12/2012, 09:45
Avatar de David
Moderador
 
Fecha de Ingreso: abril-2005
Ubicación: In this planet
Mensajes: 15.720
Antigüedad: 19 años
Puntos: 839
Respuesta: Contador de visitas para post

¿Podrías poner el código donde ejecutas esa consulta?
__________________
Por favor, antes de preguntar, revisa la Guía para realizar preguntas.
  #5 (permalink)  
Antiguo 09/12/2012, 09:51
 
Fecha de Ingreso: marzo-2011
Mensajes: 115
Antigüedad: 13 años, 1 mes
Puntos: 0
Respuesta: Contador de visitas para post

[HIGHLIGHT="PHP"]
Código PHP:
Ver original
  1. <?php require('/Connections/hoysale.php'); ?>
  2. <?php $updateSQL = ("UPDATE formulario_clasificados SET visitas=visitas+1 WHERE id_rubro=%s");?>
  3. <?php
  4. if (!function_exists("GetSQLValueString")) {
  5. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  6. {
  7.   if (PHP_VERSION < 6) {
  8.     $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  9.   }
  10.  
  11.   $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  12.  
  13.   switch ($theType) {
  14.     case "text":
  15.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  16.       break;    
  17.     case "long":
  18.     case "int":
  19.       $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  20.       break;
  21.     case "double":
  22.       $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  23.       break;
  24.     case "date":
  25.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  26.       break;
  27.     case "defined":
  28.       $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  29.       break;
  30.   }
  31.   return $theValue;
  32. }
  33. }
  34.  
  35. $colname_detallesdelclasificado = "-1";
  36. if (isset($_GET['ver'])) {
  37.   $colname_detallesdelclasificado = $_GET['ver'];
  38. }
  39. mysql_select_db($database_hoysale, $hoysale);
  40. $query_detallesdelclasificado = sprintf("SELECT * FROM formulario_clasificados WHERE id_rubro = %s", GetSQLValueString($colname_detallesdelclasificado, "int"));
  41. $detallesdelclasificado = mysql_query($query_detallesdelclasificado, $hoysale) or die(mysql_error());
  42. $row_detallesdelclasificado = mysql_fetch_assoc($detallesdelclasificado);
  43. $totalRows_detallesdelclasificado = mysql_num_rows($detallesdelclasificado);
  44. ?>
  45.  
  46.  
  47. <?php
  48. mysql_free_result($detallesdelclasificado);
  49. ?>

la parte html la pongo en otro comentario porque no me deja agregar mas
  #6 (permalink)  
Antiguo 09/12/2012, 09:53
Avatar de David
Moderador
 
Fecha de Ingreso: abril-2005
Ubicación: In this planet
Mensajes: 15.720
Antigüedad: 19 años
Puntos: 839
Respuesta: Contador de visitas para post

En ningún momento estás ejecutando la consulta.
Véase: http://php.net/mysql_query
Véase también: http://www.forosdelweb.com/f18/anunc...ecada-1008145/
__________________
Por favor, antes de preguntar, revisa la Guía para realizar preguntas.
  #7 (permalink)  
Antiguo 09/12/2012, 09:55
 
Fecha de Ingreso: marzo-2011
Mensajes: 115
Antigüedad: 13 años, 1 mes
Puntos: 0
Respuesta: Contador de visitas para post

Cita:
Iniciado por David Ver Mensaje
En ningún momento estás ejecutando la consulta.
Véase: [url]http://php.net/mysql_query[/url]
Véase también: [URL]http://www.forosdelweb.com/f18/anuncio-extension-mysql-ha-sido-deprecada-1008145/[/URL]

no se como hacerlo jejej
muchas gracias !!!

Etiquetas: contador, formulario, post, sql
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 19:32.