0

Hello all,

I'm sorry to keep bugging everyone with my code debugging requests... I recently got help with this line of my code, but I am still getting error messages about a missing ; or , .

Here is the line of code:

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

The error message says:
syntax error, unexpected T_LNUMBER, expecting ',' or ';'

....please help!

3
Contributors
7
Replies
9
Views
7 Years
Discussion Span
Last Post by almostbob
0

This code segment seems to be fine. This error doesn't show the line number? Try to find the last things you've worked, the syntax error is there.

Edited by martin5211: n/a

0

Hi, thx for your response..
The error references line 99 which is this line of code exactly. This line of code is actually the last line of code that I changed. The entire code is here:

<?php

  // Get the search variable from URL
  $var = @$_GET['q'] ;
  $trimmed = trim($var); //trim whitespace from the stored variable

// rows to return
$limit=10; 

// check for an empty string and display a message.
if ($trimmed == "")
  {
  echo "<p>Please enter a search...</p>";
  exit;
  }

// check for a search parameter
if (!isset($var))
  {
  echo "<p>We dont seem to have a search parameter!</p>";
  exit;
  }

//connect to your database ** EDIT REQUIRED HERE **
mysql_connect("localhost","xxxxxx","xxxxx");


mysql_select_db("xxxxxx") or die("Unable to select database"); 


// Build SQL Query  
$query = "SELECT lastname, firstname, state, zip, jobtype, otherjobtype, nightavail, weekendavail, ptft, objective, resume FROM data WHERE jobtype LIKE '%" . $trimmed . "%' ORDER BY lastname"; 

 $numresults=mysql_query($query);
 $numrows=mysql_num_rows($numresults);

// If we have no results, offer a google search as an alternative

if ($numrows == 0)
  {
  echo "<h4>Results</h4>";
  echo "<p>Sorry, your search: &quot;" . $trimmed . "&quot; returned zero results</p>";

// google
echo "<p><a href='http://www.google.com/search?q=". $trimmed . "' target='_blank' title='Look up " . $trimmed . " on Google'>Click here</a> to try the search on google</p>";
  }

// next determine if s has been passed to script, if not use 0
  if (empty($s)) {
  $s=0;
  }

// get results
  $query .= " limit $s,$limit";
  $result = mysql_query($query) or die("Couldn't execute query");

// display what the person searched for
echo "<p>You searched for: &quot;" . $var . "&quot;</p>";

// begin to show results set
echo "Results";
$count = 1 + $s ;

// now you can display the results returned
  while ($row= mysql_fetch_array($result)) {
  $title = $row["1st_field"];

  echo "$count.)&nbsp;$title" ;
  $count++ ;
  }

$currPage = (($s/$limit) + 1);

//break before paging
  echo "<br />";

  // next we need to do the links to other results
 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>";
 
?>
0

Line 72 is:

$currPage = (($s/$limit) + 1);

I thought this would be okay since there are opening and closing parentheses.
What should this line look like?

0

If you could find the error and get this code running, I would happily pay you a small amount via paypal. This is my only source for php help and I am now desperate!

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

To my mind there are two forms of that code

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

if the variables contain anything unsanitized, the resulting code could fail

Edited by almostbob: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.