Jump to content

trying to write a loop - parse error


jarv

Recommended Posts

I get the error:

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in D:\mypubspace.com\wwwroot\phpsite\pubs.php on line 95

 

$towns  = "SELECT DISTINCT rsTown, COUNT(PubID) As PubCount FROM pubs GROUP BY rsTown  ORDER BY rsTown ASC";
$townresult = mysql_query($towns) or die(mysql_error().'<br>SQL: ' . $towns);


echo <<<EOF
<form name="form3" method="post" action="">
<select name="menu2" onChange="MM_jumpMenu('parent',this,0)" class="textbox">			
<option value="">Please choose a town!</option>
while($row1 = mysql_fetch_array($townresult)){
<option value="pubs_norm1.asp?rsTown='$row1['RSTOWN'];'">
Pubs and bars in $row1['RSTOWN']; ($row1['RSTOWN']</option>
}
</select>
</form>
EOF;

 

Please help

Link to comment
Share on other sites

This is a parse error meaning you did not close a string properly or were missing a ";" from your code.  You will want to write cleaner code so it is easier to debug this little things.  I suggest using a full blow IDE to help you debug things like this.  Alls I did was throw your code into netbeans and it told me where the errors were...I think reformatted your code to be easier on the eyes.

 

echo '<form name="form3" method="post" action="">
<select name="menu2" onChange="MM_jumpMenu(\'parent\',this,0)" class="textbox">			
<option value="">Please choose a town!</option>';
while($row1 = mysql_fetch_array($townresult)){
    echo '<option value="pubs_norm1.asp?rsTown='.$row1['RSTOWN'].'">
        Pubs and bars in '.$row1['RSTOWN'].$row1['RSTOWN'].'</option>';
}
echo '</select></form>';

Link to comment
Share on other sites

You have your loop in the middle of a HEREDOC. That's not allowed. You have conflicting quotes.

 

Try something like this:

<?php
echo <<<EOF
<form name="form3" method="post" action="">
<select name="menu2" onChange="MM_jumpMenu('parent',this,0)" class="textbox">			
<option value="">Please choose a town!</option>
EOF;
while($row1 = mysql_fetch_array($townresult)){
   echo '<option value="pubs_norm1.asp?rsTown=' .  $row1['RSTOWN'] . '">';
   echo "Pubs and bars in {$row1['RSTOWN']} ({$row1['RSTOWN']})</option>";
}
echo <<<EOF 
</select>
</form>
EOF;
?>

 

Ken

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.