Jump to content

Help with a comment script!


pepsymax

Recommended Posts

First i'll apologise as I know little about php, so bear with me if my explanation is not so good!

I've installed a php comment script (a script that allows my users to post a review on my php pages). I've installed it and it works.

However a little error occurs if I want the results to show up on more than one page. The problem is, the code is looking for a url ending with (.php). It then adds the code to forward to the next page directly after the php comment. My pages dont work as they end like this [code]index.php?&task=detail&id=7&mode=0&catid=45&navstart=0&search=*[/code]

The php comment in the code occurs too early on my pages, so the command to foward appears directly after php and forwards to the wrong page.

So! Instead of producing something like this...

[code]index.php?&task=detail&id=7&mode=0&catid=45&navstart=0&search=*NEW_PAGE_CODE[/code]

It does this

[code]index.php?NEW_PAGE_CODE[/code]

So I think the code tries to open the next page from (index.php) instead of from the end of the code (search*)

Now What I need is to rewrite the script so that it links after the (search=* ) comment.

Ok I think I've explained it... here is the code I have to change. Any ideas?

[code]<?php

# configuration
    $emptyMsg     = " Be the first to add comment to this page.";
    $size             = 40;    # size of input boxes
    $cols             = 53; # width of text areas
    $rows                = 5;    # height of text areas

    $bgColor         = "#eaeaea";

# input box length adjustment code
    $ie = stristr($HTTP_USER_AGENT, "MSIE") && true;
    $op = stristr($HTTP_USER_AGENT, "Opera") && true;
    $n6 = stristr($HTTP_USER_AGENT, "Netscape6") && true;
    $ns = (!($ie)) && (!($n6));
    $size = fw($size);
    $cols = fc($cols);

function fw($w) {
  global $ns;
  if ($ns == 1) { $w = $w * 0.8; }
  return ceil($w);
}

function fc($w) {
  global $n6;
  if ($n6 == 1) { $w = $w * 0.7; } else { $w = $w * 0.75; }
  return ceil($w);
}

# FUNCTIONS ###################################################################

# Calculate page navigation tool and define the lower and upper record numbers
    function genNav ($listID, $items, $ipp, &$lowLimit, &$topLimit) {
      $self = $_SERVER['PHP_SELF'];
        if (!isset($_GET['pID'])) { $pID = 0; } else { $pID = $_GET['pID']; }

        $str = "";
        $numberOfPages = ceil($items / $ipp);
        $lowLimit = $pID * $ipp;
        $topLimit = $lowLimit + $ipp;
        if ($topLimit > $items) { $topLimit = $items; }

        for ( $i=0; $i < $numberOfPages; $i++ ) {
            if ($i == $pID) {
                $str .= "<b>".($i+1)."</b> ";
            } else { $str .= "<a href=\"$self?pID=$i&listID=$listID#comment\">".($i+1)."</a> "; }
        }
        return $str;
    }
?>[/code]

If you need it the whole script can be found [a href=\"http://www.greatnexus.com/_downloads/commenter.php\" target=\"_blank\"]http://www.greatnexus.com/_downloads/commenter.php[/a]

Thanks

pep
Link to comment
https://forums.phpfreaks.com/topic/3941-help-with-a-comment-script/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.