Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 5 of 5
  1. #1
    Junior Member
    Join Date
    Apr 2006
    Posts
    2
    Member #
    13112
    Good day, I am creating a personal profile website and have run into a problem with a php comment system that I got to work. I can get the comment script to work on one page; however, if I include my php script on another page, it will display the same comments.


    I suppose the page URL needs to be uploaded to the database along with the other three fields, COMMENT, NAME, and WEBSITE. As of how, I do not know. Also, the script needs to filter out any database entries that do not match the page URL.

    I am probably explaining this pretty bad, here is the source of my php script
    name: Phpcomment.php
    Code:
    <?PHP
    
    $root_path = '/home/ftpusername/public_html/';
    
    $url = 'http://www.cyroxos.net/Phpcomment/';
    
    $host         = 'localhost'; //server host
    $database     = 'data'; //database name
    $user         = 'xxxxxx'; //database username
    $pass         = 'xxxxxx'; //database password
    
    $limit         = '10'; 
    
    ?>
    
    <?PHP
    $con=mysql_connect("$host","$user","$pass"); $db="$database"; mysql_select_db($db, $con);
    $svr_domain     = "http://$_SERVER[HTTP_HOST]";
    $svr_phpself     = "$_SERVER[PHP_SELF]";
    $svr_self     = "$svr_domain$svr_phpself";
    
    if (empty($_GET[limit])) $limit = $limit; else $limit = $_GET[limit];
    
    if ($_GET[shout] == 1 && $_POST[COMMENT] != $nil && $_POST[NAME] != $nil) {
        $controller     = $_POST['controller'];
        $pieces     = explode("~", $controller);
        $table         = $pieces[0];
        $qt         = $pieces[1];
        $return     = $pieces[2];
        $id         = $pieces[3];
        $hack         = $pieces[4];
    
        if ($qt == insert) 
            $qt = 'INSERT INTO';
        if ($qt == update) { 
            $qt = 'UPDATE'; $end = "WHERE ID = '$id'"; 
        }
    
        $pre         = array_keys( $_POST );
    
        mysql_query ("CREATE TABLE IF NOT EXISTS `$table` (`ID` INT NOT NULL AUTO_INCREMENT , PRIMARY KEY ( `id` ) )");
    
        $count         = count($pre); 
        $count         = $count - 2;
        $sql         = "$qt $table SET";
        
        for ($i=0; $i < $count; $i++) {
            $x    = $i+1;
            $y     = $_POST[$pre[$x]];
            $d     = $y;
    
            if ($pre[$x] == REQUIRED || $pre[$x] == NODUPE || $pre[$x] == NOPASS) {
            } else {
                mysql_query ("ALTER TABLE `$table` ADD `$pre[$x]` TEXT NOT NULL");
                $sql .= " `$pre[$x]` = '$d',";
            }
        }
    
        $sql .= " ID = '$id' $end";
        $query = mysql_query($sql) or die("$sql_error" . mysql_error());
    }
    ?>
    <FORM METHOD="post" ACTION="?shout=1">
     <INPUT TYPE="hidden" NAME="controller" VALUE="COMMENTS~insert~<?PHP ECHO "$svr_self"; ?>~<?php echo $id; ?>">
     <TABLE BORDER=0 ALIGN=center CELLPADDING=4 CELLSPACING=0 WIDTH=100%>
      <TR> 
       <TD CLASS="tdhead" WIDTH="100%" >Last 
        <?php echo $limit; ?>
        Comments [ <A HREF="?">Reload</A> ]</TD>
      </TR>
      <?PHP
    $SQL = "SELECT * from COMMENTS ORDER BY ID DESC LIMIT $limit"; $result = @mysql_query( $SQL ); while( $row = @mysql_fetch_array( $result ) ) {
    ?>
      <TR> 
       <TD CLASS="tdmenu" WIDTH="100%" > 
        <?php echo "<b>$row[NAME]</b> : $row[COMMENT]"; if ($row[WEBSITE] != $nil) { echo " [ <a href=\"$row[WEBSITE]\" target=blank>$row[NAME]'s Website</a> ]"; }?>
       </TD>
      </TR>
      <?PHP } ?>
      <TR> 
       <TD CLASS="tdmenu" WIDTH="100%" >[ <A HREF="?limit=1000">Show Last 1000</A> ]</TD>
      </TR>
     </TABLE>
     <BR>
     <TABLE BORDER=0 ALIGN=center CELLPADDING=4 CELLSPACING=0 WIDTH=100%>
      <TR>
                <TD CLASS="tdhead" colspan="2" NOWRAP>Post Comment</TD>
            </TR>
      <TR>
                <TD CLASS="tdmenu" WIDTH="1%" NOWRAP>Name</TD>
                <TD CLASS="tdmenu" WIDTH="100%" >  
        <INPUT TYPE="text" NAME="NAME" SIZE="35"></TD>
            </TR>
      <TR>
                <TD CLASS="tdmenu" WIDTH="1%" NOWRAP>Website</TD>
                <TD CLASS="tdmenu" WIDTH="100%" >  
        <INPUT TYPE="text" NAME="WEBSITE" SIZE="35" VALUE="http://www."></TD>
            </TR>
      <TR>
                <TD CLASS="tdmenu" WIDTH="1%" NOWRAP>Comment</TD>
                <TD CLASS="tdmenu" WIDTH="100%" ><textarea name="COMMENT" rows="4" cols="40"></textarea>
        </TD>
            </TR>
            <tr>
                <td class="tdmenu" width="1%" nowrap></td>
                <td class="tdmenu" width="100%"><INPUT TYPE="submit" NAME="Submit" VALUE="Add Comment"></td>
            </tr>
        </TABLE>
     </FORM>
    and it is included into the page via <?PHP INCLUDE "Phpcomment.php"; ?>

    The page: http://www.cyroxos.net/weblog.php

    I am sorry for this extensive request, but I must say, it has me very confused. Thank you.

  2.  

  3. #2
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    I do not understand what you seek,

    Do you want to display the blog but without the comments?

  4. #3
    Member
    Join Date
    Apr 2006
    Posts
    45
    Member #
    13115
    I don't understand what you mean either. Please give more details.

  5. #4
    Junior Member
    Join Date
    Apr 2006
    Posts
    2
    Member #
    13112
    Once again, I am sorry for being unclear.
    I want to be able to use this comment system on multiple pages--Such that each page has unique comments to that page. At the moment, wherever I put the script, the comments get uploaded to the same place in my mysql database.
    So what I need is a way to add a field that detects the page URL and uploads it along with the other comment fields. Then, when the scrip displays the data on the page, I need a way for it to filter out only the uploaded comments that have a matching page URL.

    Is this any more clear? I am sorry.

  6. #5
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    Ah I see, like if the page is "value1.php" only display comments where it's page (or other column name) is equal to "value1.php"

    The way I do this is, I have two tables, one for the posts/articles that you make, and one for the comments.

    When a new comment is added I insert the post/article id into a int column in the comments table.

    Then, to extract the comments for a particular post/article, your query would be like:
    PHP Code:
    $select_q "SELECT * FROM comments WHERE aid = $aid"
    Where $aid is the post/article id number.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 10:04 AM.
Powered by vBulletin® Version 4.2.0
Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com