Unstoppable Domains

Argh... hate php... what is with this error mesage???

Spaceship Spaceship
Watch

PoorDoggie

Soon to be RICHdoggie!VIP Member
Impact
18
My PHP Script said:
Parse error: parse error, unexpected $ in /homepages/43/d121401701/htdocs/beta/search/index.php on line 201

I get this message, athough my script ends exactlly on line 200! :( What is wrong? Why won't it work! :(
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
oh lol i used to get the same error. check the syntax on line 200 cuz the error is usually on the line before.

in my case, i was missing a semicolon :D

try posting the code here so we can see it.
 
0
•••
Either (A) Post the contents of the script for review, or (B) Check all instances of "$" in your script to find the errand one, or (C), check the lines starting from 200 going up, sometimes the actual error is a few lines prior to the reported one.
 
0
•••
You're most likely missing a semi colon on the end of one of your arguments.

Post the code and we'll try to help

-Steve
 
1
•••
plain simple, $ shouldn't be used somwehre in that line. mostly, this error comes from a person typing a double $$ by mistake for a variable name, or singling a $ in a statement.
 
0
•••
legend2 said:
plain simple, $ shouldn't be used somwehre in that line. mostly, this error comes from a person typing a double $$ by mistake for a variable name, or singling a $ in a statement.
This might have been true in another situation, but if you look at the original thread, you will see that their script is only 200 lines long:
PoorDoggie said:
My PHP Script said:
Parse error: parse error, unexpected $ in /homepages/43/d121401701/htdocs/beta/search/index.php on line 201

I get this message, athough my script ends exactlly on line 200! :( What is wrong? Why won't it work! :(
This ultimately means that the coder forgot to end an argument line with the approiate close - ";".

PHP:
<?
// Example of this error
if 1==1 {
$true = 1
}
else {
$true = 2;
}
?>
As you can see, there is no semi colon after;
PHP:
$true = 1
which looks until it finds the end of that line. It searches until the end of the script, and then breaks, and says it could not find the end of the argument, through the whole document.

In this case, PHP would output an error like
Broken PHP said:
Parse error: parse error, unexpected $ in /path/to/documenet/on/server/namepros.php on line 8

-Steve
 
1
•••
Meh, for me, it's usually a forgotten ; or } Lol. :p
 
0
•••
1
•••
here is the php code... sorry about not including it before.

PHP:
<?php

// search.php

// ok lets get the variables to start off with:
$q = (isset($HTTP_GET_VARS['q'])) ? $HTTP_GET_VARS['q'] : "";
$q = stripslashes($q);
// $country = (isset($HTTP_GET_VARS['c'])) ? $HTTP_GET_VARS['c'] : "";


$title = "PoorDoggie - Search";
if(!empty($q)){ $title .= " '".stripslashes($q)."'"; }

if(empty($q)){
  header("Location: ../index.php");
}

// lets now connect to the database:
include "../config.php";

$sql = "SELECT * FROM pd_shops WHERE MATCH (name, description, keywords) AGAINST ('$q' IN BOOLEAN MODE)";

$m = 10;
$a = (isset($HTTP_GET_VARS['p'])) ? ($HTTP_GET_VARS['p']-1)*$m : 0;
if(isset($HTTP_GET_VARS['p'])){
  $sql .= " LIMIT $a, 10";
}

// $sql = "SELECT * FROM pd_shops WHERE name LIKE '%$q%' OR description LIKE '%$q%' OR keywords LIKE '%$q%' ORDER BY hit_count DESC";

$result = mysql_query($sql);

// here is the content variable:
$content = '<table class="main" width="700">';

$f = 0;
$l = 1;

while($row = mysql_fetch_array($result)){
  $content .= '<tr><td rowspan="2" valign="top"><a href="clickthru.php?id=';
  $content .= $row['id'];
  $content .= '"><img src="';
  $content .= $row['image'];
  $content .= '" style="border: 0" alt="';
  $content .= $row['name'];
  $content .= '" /></td><td width="100%" valign="top"><a href="clickthru.php?id=';
  $content .= $row['id'];
  $content .= '">';
  $content .= $row['name'];
  $content .= '</a></td></tr><tr><td valign="top" align="justified">';
//  $content .= substr($row['description'],0,255);
  $content .= $row['description'];
  $content .= '...</td></tr><tr><td colspan="2"> </td></tr>';
  $l++;
}

$content .= '</table>';

$sql = "SELECT * FROM pd_shops WHERE MATCH (name, description, keywords) AGAINST ('$q' IN BOOLEAN MODE)";

$result = mysql_query($sql);

while($row = mysql_fetch_array($result)){
  if(!empty($row['tall_banner'])){
    $banners[$f] = $row['tall_banner'];
    $url[$f] = $row['url'];
    $f++;
  }
}

$i = mysql_num_rows($result);

if($i < 1){
  $content = "<center><span class=\"main\">Your search returned no results.<br /><br />If you are having trouble try cutting your search queries down to 1 word phrases.</span></center>";

if(isset($banners[0])){
  srand((float) microtime() * 10000000);
  $rand_keys = array_rand($banners, 1);
  $ad = '<a href="';
  $ad .= $url[$rand_keys];
  $ad .= '"><img border="0" alt="Click Here!" src="';
  $ad .= $banners[$rand_keys];
  $ad .= '" /></a>';
}
else{
  $ad = "";
}

if($i > 10){
  $r = $a+$m;
  $t = $r-$i;
  if(0<$t && $t<10){
    $r = $a+($m-$t);
  }
  $results = "Showing $a-$r of $i results";
}
else{
  $results = "Showing $i Results";
}

$p = (isset($HTTP_GET_VARS['p'])) ? $HTTP_GET_VARS['p']++ : "1";

// lets do the page numbers
$nop = $i/$m; // num of pages total (ish)
$pg = 1;
$pages_box = '<select name="pages" id="pages" onChange="location.href=\'index.php?q=';
$pages_box .= $q;
$pages_box .= '&p=\'+this.value">';

while($nop>$pg){
  $pages_box .= '<option value="';
  $pages_box .= $pg;
  $pages_box .= '">';
  $pages_box .= $pg;
  $pages_box .= '</option>';
  $pg++;
}

$pages_box .= '</select>';

$next = $p+1;
$prev = $p-1;

$nav  = '<table><tr><td valign="bottom" rowspan="2">';
$nav .= ($p > 1) ? '<a href="index.php?q='.$q.'&p='.$prev.'"><img src="../images/nav/prev.gif" alt="Go back one page..."></a>' : '<img src="../images/nav/prevpaw.gif" alt="PoorDoggie Web Directory">';
$nav .= '</td><td valign="bottom" align="center"><img src="../images/nav/goto.gif" alt="Go to page.."></td><td valign="bottom" rowspan="2">';
$nav .= ($p < $pg) ? '<a href="index.php?q='.$q.'&p='.$next.'"><img src="../images/nav/next.gif" alt="Go back one page..."></a>' : '<img src="../images/nav/nextpaw.gif" alt="PoorDoggie Web Directory">';
$nav .= '</td></tr><tr><td align="center" valign="bottom">'.$pages_box.'</td></tr></table>';

?>

<html>

<head>
  <title><?php echo $title; ?></title>
  <meta name="description" content="A large web directory with countless sites." />
  <meta name="keywords" content="web, directory, search, sites" />
  <style>
    body{
      font-family: arial, tahoma, serif;
      font-size: 12px;
    }
    a, a:visited, a:active{
      color: 6c96ba;
    }
    a:hover{
      color: 89ba6c;
      text-decoration: none;
    }
    .description, .main{
      font-size: 12px;
    }
    .search{
      background: 89ba6c;
    }
    .query_bar{
      background: 6c96ba;
      color: #ffffff;
    }
    img{
      border: 0;
    }
  </style>
</head>

<body onLoad="document.all.q.focus()">
  <center>
  <table class="main" width="800">
    <tr>
      <td align="left"><a href="../index.php"><img src="../images/logo.gif" alt="PoorDoggie - The web directory!" /></a></td>
    </tr>
    <tr>
      <form method="get" action="index.php">
        <td class="search" width="100%" align="center"><input id="q" name="q" style="width: 254" value="<?php echo stripslashes($q); ?>" /> <input type="submit" value="Search" style="width: 55px;"/></td>
      </form>
    </tr>
    <tr>
      <td class="query_bar" align="right">Search results for "<?php echo $q; ?>" - <?php echo $results; ?></td>
    </tr>
    <tr>
      <td>
        <table width="100%">
          <tr>
            <td valign="top" width="700"><?php echo $content; ?></td>
            <td valign="top" align="right"><?php echo $ad; ?></td>
          </tr>
        </table>
      </td>
    </tr>
    <tr>
      <td valign="top" align="center">
        <?php echo $nav; ?>
      </td>
    </tr>
  </table>
  </center>
  
</body>

</html>

There is an include... will that make more "lines"? When I paste the content of that page into this page then there is just HTML on line 201.

Aha! :) I have found the problem! :) I was missing a curly bracket here:

PHP:
if($i < 1){ 
  $content = "<center><span class=\"main\">Your search returned no results.<br /><br />If you are having trouble try cutting your search queries down to 1 word phrases.</span></center>";

and now it works... thanks to Axillant's helpful link! :) Thanks a lot! :)

http://codewalkers.com/tutorials/17/3.html said:
PHP:
Parse error: parse error, unexpected ? in ?????????? on line 265
How can this be when the file is only 264 lines long? You've forgotten to close a brace '}' somewhere in your code. Get yourself a editor that can show you where the brace/bracket starts/ends when your cursor is on it. Also, with proper auto-indenting, this should never be an issue.
 
0
•••
Your missing a } count all the { and }'s there should be a even not odd amount
 
0
•••
Dynadot — .com Registration $8.99Dynadot — .com Registration $8.99

We're social

Unstoppable Domains
Domain Recover
DomainEasy — Payment Flexibility
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back