Ver Mensaje Individual
  #1 (permalink)  
Antiguo 25/08/2012, 14:40
ofertasdiarias
 
Fecha de Ingreso: marzo-2011
Mensajes: 115
Antigüedad: 13 años
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 !!!