Hi again all,
Can anyone see what is wrong with the code below?

if ($s>=1) {
  $prevs=($s-$limit);
  print "&nbsp;<a href=\\"$PHP_SELF?s=$prevs&q=$var\\">&lt;&lt; Prev 10</a>&nbsp&nbsp;";
  }

I keep getting an error message:
Parse error: syntax error, unexpected T_VARIABLE

...referencing the print line.

Try each of the following

if ($s>=1) {
  $prevs=($s-$limit);
  print "&nbsp;<a href=\"$PHP_SELF?s=$prevs&q=$var\">&lt;&lt; Prev 10</a>&nbsp&nbsp;";
  }
if ($s>=1) {
  $prevs=($s-$limit);
  print "&nbsp;<a href=\\\"$PHP_SELF?s=$prevs&q=$var\\\">&lt;&lt; Prev 10</a>&nbsp&nbsp;";
  }

The difference? The first code box has the regular syntax for escaping a quote. However the second code box will output a single backslash before the quote. Also I noticed you didn't use the $PHP_SELF correctly. Perhaps the following?

if ($s>=1) {
  $prevs=($s-$limit);
  print '&nbsp;<a href="'.$PHP_SELF.'?s=$prevs&q=$var">&lt;&lt; Prev 10</a>&nbsp&nbsp;';
  }
print "&nbsp;<a href='$_SERVER['PHP_SELF']?s=$prevs&q=$var'>&lt;&lt; Prev 10</a>&nbsp&nbsp;";

php5
unexpected t_variable:: $PHP_SELF does not exist in php5

print "&nbsp;<a href='$_SERVER['PHP_SELF']?s=$prevs&q=$var'>&lt;&lt; Prev 10</a>&nbsp&nbsp;";

php5
unexpected t_variable:: $PHP_SELF does not exist in php5

I was a bit suspect about that variable. It is $PHP_SELF only when globals are enabled. However as of php5 globals have been depreciated. Also almost bob's script has a bug. You forgot the {} brackets around the array. But here is the corrected example (my version).

if ($s>=1) {
  $prevs=($s-$limit);
  print '&nbsp;<a href="'.$_SERVER['PHP_SELF'].'?s=$prevs&q=$var">&lt;&lt; Prev 10</a>&nbsp&nbsp;';
  }

Here is almost bobs script corrected.

print "&nbsp;<a href='{$_SERVER['PHP_SELF']}?s=$prevs&q=$var'>&lt;&lt; Prev 10</a>&nbsp&nbsp;";

thanks muchly, went googling to find whi it looked wrong,
found the braces and came back, already fixed

Thanks guys.
I switched the code to the one above and looks like that line is working. BUT I'm having real trouble
with the rest of the code, especially around line 13 shown below:

if ($s>=1) {
  $prevs=($s-$limit);
  print '&nbsp;<a href="'.$_SERVER['PHP_SELF'].'?s=$prevs&q=$var">&lt;&lt; Prev 10</a>&nbsp&nbsp;';
  }

// calculate number of pages needing links
  $pages=intval($numrows/$limit);

// $pages now contains int of pages needed unless there is a remainder from division

  if ($numrows%$limit) {
  // has remainder so add one page
  $pages++;
  }

// check to see if last page
  if (!((($s+$limit)/$limit)==$pages) && $pages!=1) {

  // not last page so give NEXT link
  $news=$s+$limit;

  echo "&nbsp;<a href=\\"$PHP_SELF?s=$news&q=$var\\">Next 10 &gt;&gt;</a>";
  }

$a = $s + ($limit) ;
  if ($a > $numrows) { $a = $numrows ; }
  $b = $s + 1 ;
  echo "<p>Showing results $b to $a of $numrows</p>";
  
?>

I get this error:
Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';'

I think the issue is that I copied and pasted this code from an old forum from 2005 and a lot has probably been updated since then...
If someone could give me a clue here as to what is possibly wrong in the rest of my code, Id greatly appreciate it...

if ($s>=1) {
  $prevs=($s-$limit);
  print '&nbsp;<a href="'.$_SERVER['PHP_SELF'].'?s=$prevs&q=$var">&lt;&lt; Prev 10</a>&nbsp&nbsp;';
  }

// calculate number of pages needing links
  $pages=intval($numrows/$limit);

// $pages now contains int of pages needed unless there is a remainder from division

  if ($numrows%$limit) {
  // has remainder so add one page
  $pages++;
  }

// check to see if last page
  if (!((($s+$limit)/$limit)==$pages) && $pages!=1) {

  // not last page so give NEXT link
  $news=$s+$limit;

  echo '&nbsp;<a href="'.$_SERVER['PHP_SELF']."?s=$news&q=$var\">Next 10 &gt;&gt;</a>";
  }

$a = $s + ($limit) ;
  if ($a > $numrows) { $a = $numrows ; }
  $b = $s + 1 ;
  echo "<p>Showing results $b to $a of $numrows</p>";
  
?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.