Ver Mensaje Individual
  #1 (permalink)  
Antiguo 18/04/2010, 18:48
Avatar de reborn
reborn
 
Fecha de Ingreso: febrero-2010
Mensajes: 440
Antigüedad: 14 años, 2 meses
Puntos: 1
Ayuda con sistema de comentarios ya hecho.

Buenas, tengo un sencillo sistema de comentarios pero no se por q no lo puedo hacer funcionar ya q segui todos los pasos segun lo indicaba:
Consta de 4 archivos:
-setting.php (no lo pongo entero, solo lo mas importante q donde me dice q cambie la url por la mia y las variables q llevan a los distintos mensajes)
Código PHP:
<?php    
$dir_url    
='http://miurl/directoriocomentarios/';
$dir        ='data/'
$ext        ='.html';

$file        "$dir$id$ext";
$view_file     "$dir_url$dir$page_id$ext";

$page    $_SERVER['HTTP_REFERER']; 
$ip        $_SERVER['REMOTE_ADDR'];


$no_name    "You did not enter your name!"// When Name is not entered.
$no_email    "You did not  enter your email address!"// When Email is not entered.
$inv_email    "You have entered an invalid email address!"// When Email id is invalid
$no_cmn        "You should enter your comments!"// No no comments entered.
$thanks        "Thank you <b>$name</b> for posting your valuable comments!"// Thanks message when a comments is posted
$no_id_post    "Sorry! No page id mentioned. Comments can't be posted!"// Error message to notify you incase you forget to add a page id to post comments.
$no_id_view    "Sorry! No page id mentioned. Comments can't be viewed!";// Error message to notify you incase you forget to add a page id to view comments.
$no_post        "No comments posted here yet!"// When no comments is available for a page.
$error_time    "3"// Seconds to show error or thanks page
$title_error    "Error Occured!"// Ttitle of page when error occurs
$title_ok        "Thank You!"// Ttitle of page when error occurs
$send_back    "You shall be send back to the previous page automatically within $error_time seconds.<br><a href='$page'>If it does not work click here to go back.</a>"// This line shows a send back line so that visiors can go back to previous page from error or thanks page.

?>
Luego esta el archivo view.php y post.php q son los q me originan el problema.

view
Código PHP:
<?php
include('settings.php');

if (
$page_id=="demo")
    {
    echo 
$format_no_id_view;
    }
    
else
    {
    
$fp        fopen$view_file,"r"); 
    
$data        fread($fp80000);
    
fclose$fp );
    
    
$data_array     split ("$spilter"$data);
    
$total_post    count($data_array) - 1;
    
    
$data_format "$data<b>Total $total_post comments posted here so far.</b>";
    
    if (
total_post =="0")
    {
    echo 
$no_post;
    }
    else
    {
    echo 
$data_format;
    }
    }
?>
post: al id q se recoge por GET lo cambie por el id de la noticia donde va el sistema
Código PHP:
<?php

$id    
$_GET['id'];

include(
'settings.php');
        
// Validate ID
if ($id=="")
    {
    echo 
"$format_no_id_post";
    }
else
// Form Validation 
    
{    
    if (
$name == "")
     {
    echo 
$format_no_name
    }    
    else if (
$email == "")
     {
    echo 
$format_no_email
    }    
    else if (
eregi("^[a-zA-Z0-9_.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]"$email)) 
    { 
        echo 
$format_inv_email;
    }    
    else if (
$comment == "")
     {
    echo 
$format_no_cmn
    }
    
//// If form  is valid, contnue processing     
    
else
    {
    
$fp fopen$file,"r"); 
    
$old_data fread($fp80000); 
    
fclose$fp ); 
    
$write    ="$format$spilter$old_data";
    
    
$fp fopen$file,"w"); 
    if(!
$fp) die("<b>Failed to post your comments. Sorry!</b>");
    
fwrite($fp$write800000); 
    
fclose$fp ); 
    
    echo 
"    $format_thanks";
    }
}
?>
Bueno, en la instalacion me dice q suba esos archivos y tambien q cree una carpeta "data" y a esa carpeta darle permisos 777 y asi poder crear el .html para ver los mensajes.
Tambien me dice, q en donde vaya a incluir los comentarios agregue el siguiente codigo:
Código PHP:
<?php
$page_id 
="demo";
include(
'form.php');
include(
'view.php');
?>
...en donde $page_id ="demo" es la pagina html q va a crear para guardar los comentarios, yo le cambie por otro nombre.
Bueno, y eso es lo q me origina el error, segui todos los pasos tal cual me dice pero al probar si funciona, se ve el formulario de comentarios pero abajo me sale el siguiente error:
$no_id_view = "Sorry! No page id mentioned. Comments can't be viewed!" (lo puse con la variable q trae el error q se encuentra en settings).

La verdad no se donde le estoy fallando.

Gracias.
Saludos.

Última edición por reborn; 18/04/2010 a las 19:58