Foros del Web » Programando para Internet » PHP »

sistema de comentarios ?

Estas en el tema de sistema de comentarios ? en el foro de PHP en Foros del Web. hola tengo este script : uno.php @import url("http://static.forosdelweb.com/clientscript/vbulletin_css/geshi.css"); Código PHP: Ver original <?php require ( '/Connections/hoysale.php' ) ; ?> <?php if ( ! function_exists ( ...
  #1 (permalink)  
Antiguo 25/08/2012, 14:40
 
Fecha de Ingreso: marzo-2011
Mensajes: 115
Antigüedad: 13 años, 1 mes
Puntos: 0
sistema de comentarios ?

hola tengo este script :

uno.php

Código PHP:
Ver original
  1. <?php require('/Connections/hoysale.php'); ?>
  2. <?php
  3. if (!function_exists("GetSQLValueString")) {
  4. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  5. {
  6.   if (PHP_VERSION < 6) {
  7.     $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  8.   }
  9.  
  10.   $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  11.  
  12.   switch ($theType) {
  13.     case "text":
  14.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  15.       break;    
  16.     case "long":
  17.     case "int":
  18.       $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  19.       break;
  20.     case "double":
  21.       $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  22.       break;
  23.     case "date":
  24.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  25.       break;
  26.     case "defined":
  27.       $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  28.       break;
  29.   }
  30.   return $theValue;
  31. }
  32. }
  33.  
  34. $colname_des = "-1";
  35. if (isset($_GET['ir'])) {
  36.   $colname_des = $_GET['ir'];
  37. }
  38. mysql_select_db($database_hoysale, $hoysale);
  39. $query_des = sprintf("SELECT * FROM formulario WHERE id_rubro = %s ORDER BY id_rubro DESC", GetSQLValueString($colname_des, "int"));
  40. $des = mysql_query($query_des, $hoysale) or die(mysql_error());
  41. $row_des = mysql_fetch_assoc($des);
  42. $totalRows_des = mysql_num_rows($des);
  43.  
  44. mysql_select_db($database_hoysale, $hoysale);
  45. $query_pre = "SELECT * FROM comentarios";
  46. $pre = mysql_query($query_pre, $hoysale) or die(mysql_error());
  47. $row_pre = mysql_fetch_assoc($pre);
  48. $totalRows_pre = mysql_num_rows($pre);
  49. ?>
  50. <html>
  51. <head>
  52. <title>Sistema de noticias</title>
  53.  
  54. </head>
  55. <body>
  56. <p><?php echo $row_des['Descripcion']; ?> &nbsp;
  57.   <a href="/unos.php?ir=<?php echo $row_des['id_rubro']; ?>">preguntar</a>
  58. </p>
  59. <?php do { ?>
  60.   <p><?php echo $row_pre['comentario']; ?></p>
  61.   <?php } while ($row_pre = mysql_fetch_assoc($pre)); ?>
  62. </body>
  63. </html>
  64. <?php
  65.  
  66. ?>

y unos.php
Código PHP:
Ver original
  1. <?php require('/Connections/hoysale.php'); ?>
  2. <?php
  3. if (!function_exists("GetSQLValueString")) {
  4. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  5. {
  6.   if (PHP_VERSION < 6) {
  7.     $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  8.   }
  9.  
  10.   $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  11.  
  12.   switch ($theType) {
  13.     case "text":
  14.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  15.       break;    
  16.     case "long":
  17.     case "int":
  18.       $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  19.       break;
  20.     case "double":
  21.       $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  22.       break;
  23.     case "date":
  24.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  25.       break;
  26.     case "defined":
  27.       $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  28.       break;
  29.   }
  30.   return $theValue;
  31. }
  32. }
  33.  
  34. $editFormAction = $_SERVER['PHP_SELF'];
  35. if (isset($_SERVER['QUERY_STRING'])) {
  36.   $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
  37. }
  38.  
  39. if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  40.   $insertSQL = sprintf("INSERT INTO comentarios (nombre, comentario) VALUES (%s, %s)",
  41.                        GetSQLValueString($_POST['nombre'], "text"),
  42.                        GetSQLValueString($_POST['comentario'], "text"));
  43.  
  44.   mysql_select_db($database_hoysale, $hoysale);
  45.   $Result1 = mysql_query($insertSQL, $hoysale) or die(mysql_error());
  46.  
  47.   $insertGoTo = "/uno.php";
  48.   if (isset($_SERVER['QUERY_STRING'])) {
  49.     $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
  50.     $insertGoTo .= $_SERVER['QUERY_STRING'];
  51.   }
  52.   header(sprintf("Location: %s", $insertGoTo));
  53. }
  54.  
  55. $colname_pre = "-1";
  56. if (isset($_GET['ir'])) {
  57.   $colname_pre = $_GET['ir'];
  58. }
  59. mysql_select_db($database_hoysale, $hoysale);
  60. $query_pre = sprintf("SELECT * FROM comentarios WHERE id_entrada = %s ORDER BY id DESC", GetSQLValueString($colname_pre, "int"));
  61. $pre = mysql_query($query_pre, $hoysale) or die(mysql_error());
  62. $row_pre = mysql_fetch_assoc($pre);
  63. $totalRows_pre = mysql_num_rows($pre);
  64. ?>
  65. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  66. <html xmlns="http://www.w3.org/1999/xhtml">
  67. <head>
  68. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  69. <title>Documento sin título</title>
  70. </head>
  71.  
  72. <body>
  73. <form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
  74.   <table align="center">
  75.     <tr valign="baseline">
  76.       <td nowrap="nowrap" align="right">Nombre:</td>
  77.       <td><input type="text" name="nombre" value="" size="32" /></td>
  78.     </tr>
  79.     <tr valign="baseline">
  80.       <td nowrap="nowrap" align="right" valign="top">Comentario:</td>
  81.       <td><textarea name="comentario" cols="50" rows="5"></textarea></td>
  82.     </tr>
  83.     <tr valign="baseline">
  84.       <td nowrap="nowrap" align="right">&nbsp;</td>
  85.       <td><input type="submit" value="Insertar registro" /></td>
  86.     </tr>
  87.   </table>
  88.   <input type="hidden" name="MM_insert" value="form1" />
  89. </form>
  90. <p>&nbsp;</p>
  91. </body>
  92. </html>
  93. <?php
  94. ?>

no se en que estoy fallando para la pregunta sea segun la publicacion que aparece?

si me pueden ayudar muchas gracias !!!
  #2 (permalink)  
Antiguo 25/08/2012, 15:01
Avatar de djsos  
Fecha de Ingreso: septiembre-2007
Ubicación: Madrid-España
Mensajes: 374
Antigüedad: 16 años, 7 meses
Puntos: 14
Respuesta: sistema de comentarios ?

Deberías indicar que error te devuelve ya que al no tener hoysale.php no podemos probar tu script.
__________________
Es de bien nacidos ser agradecidos.
Desarrollo de software a medida | TPV Comercios
  #3 (permalink)  
Antiguo 25/08/2012, 15:17
 
Fecha de Ingreso: marzo-2011
Mensajes: 115
Antigüedad: 13 años, 1 mes
Puntos: 0
Respuesta: sistema de comentarios ?

no me devuelve error :


Cita:
Iniciado por djsos Ver Mensaje
Deberías indicar que error te devuelve ya que al no tener hoysale.php no podemos probar tu script.
como al no tener hoysale.php?

tengo 2 bases de datos una "formulario"

Código MySQL:
Ver original
  1. -- Estructura de tabla para la tabla `formulario`
  2. --
  3.  
  4. CREATE TABLE IF NOT EXISTS `formulario` (
  5.   `id_rubro` int(11) NOT NULL AUTO_INCREMENT,
  6.   `ubicacion` varchar(255) DEFAULT NULL,
  7.   `Barrio` varchar(255) DEFAULT NULL,
  8.   `compartir` int(11) DEFAULT NULL,
  9.   `precio` varchar(255) DEFAULT NULL,
  10.   `antes` varchar(100) DEFAULT NULL,
  11.   `ahora` varchar(100) DEFAULT NULL,
  12.   `descuento` varchar(100) DEFAULT NULL,
  13.   `fechadeinicio` date DEFAULT NULL,
  14.   `fechadecierre` date DEFAULT NULL,
  15.   `Moneda` varchar(255) DEFAULT NULL,
  16.   `tipo_de_pago` varchar(255) DEFAULT NULL,
  17.   `Titulo` varchar(255) DEFAULT NULL,
  18.   `Descripcion` varchar(255) DEFAULT NULL,
  19.   `Direccion` varchar(255) DEFAULT NULL,
  20.   `Codigo_Postal` varchar(255) DEFAULT NULL,
  21.   `email` varchar(255) DEFAULT NULL,
  22.   `Repetir_Email` varchar(255) DEFAULT NULL,
  23.   `telefono` varchar(255) DEFAULT NULL,
  24.   `Repetir_Telefono` varchar(255) DEFAULT NULL,
  25.   `contactarme_por_tel` varchar(255) DEFAULT NULL,
  26.   `Imagen` varchar(255) DEFAULT NULL,
  27.   `Imagen0` varchar(255) DEFAULT NULL,
  28.   `fecha` datetime DEFAULT NULL,
  29.   `id_mensajes` int(11) DEFAULT NULL,
  30.   `id_categoria` int(11) DEFAULT NULL,
  31.   `id_clas` int(11) DEFAULT NULL,
  32.   `id_ofertas` int(11) DEFAULT NULL,
  33.   PRIMARY KEY (`id_rubro`)

y la otra "comentarios"

Código MySQL:
Ver original
  1. CREATE TABLE IF NOT EXISTS `comentarios` (
  2.   `id` int(11) NOT NULL AUTO_INCREMENT,
  3.   `nombre` varchar(255) CHARACTER SET utf16 COLLATE utf16_spanish_ci DEFAULT NULL,
  4.   `correo` varchar(180) COLLATE utf8_spanish_ci DEFAULT NULL,
  5.   `comentario` longtext COLLATE utf8_spanish_ci,
  6.   `fecha` date DEFAULT NULL,
  7.   `id_entrada` int(11) NOT NULL,
  8.   PRIMARY KEY (`id`)
  9. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci AUTO_INCREMENT=1 ;

son solo 2 paginas en una muestra la descripcion de la noticia o anuncio y tiene un link para poder hacerle una pregunta en el cual paso el id de la misma . y en la otra paso por parametro $_get el id para poder contestar esa pregunta. hasta aqui lo eh logrado hacer.


lo que no logro es que en la base "comentarios" me aparezca la repuesta a esa pregunta o sea que si en formunario tengo una pregunta cuyo id es 10 en "comentarios" aparezca : id_entrada 10 que en este momento es lo que no eh podido lograr.
  #4 (permalink)  
Antiguo 25/08/2012, 15:32
Avatar de djsos  
Fecha de Ingreso: septiembre-2007
Ubicación: Madrid-España
Mensajes: 374
Antigüedad: 16 años, 7 meses
Puntos: 14
Respuesta: sistema de comentarios ?

En la linea 40 donde haces el insert en comentarios no le insertas el id de las noticias que has traido arrastrado desde la pagina de la noticia
__________________
Es de bien nacidos ser agradecidos.
Desarrollo de software a medida | TPV Comercios
  #5 (permalink)  
Antiguo 25/08/2012, 17:37
 
Fecha de Ingreso: marzo-2011
Mensajes: 115
Antigüedad: 13 años, 1 mes
Puntos: 0
Respuesta: sistema de comentarios ?

aun sin resolver???
  #6 (permalink)  
Antiguo 31/08/2012, 08:39
Avatar de legomolina  
Fecha de Ingreso: junio-2011
Ubicación: Valencia
Mensajes: 165
Antigüedad: 12 años, 10 meses
Puntos: 3
Respuesta: sistema de comentarios ?

Hola, a ver, lo que tienes es algo(notícia...) sobre lo que se pueden hacer comentarios, no?
Si es así, yo haría lo siguiente, cogería cada noticia y crearía una carpeta para cada una con sus imágenes... y un txt en el que se vayan guardando todos los comentarios cada uno en una línea o un txt para cada comentario como veas y luego una sencilla función que los vaya leyendo uno a uno y ya. De esta manera lo tendrías más organizado y sólo tienes que ver cada id de noticia con que comentario toca que también se puede hacer con una sencilla función. Así tendrías cada cosa en su propia carpeta con sus imágenes, comentarios y demás.
Espero haberte ayudado.

Etiquetas: comentarios, formulario, html, mysql, registro, sistema, 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 12:39.