jarv Posted September 28, 2010 Share Posted September 28, 2010 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 Quote Link to comment Share on other sites More sharing options...
s0c0 Posted September 28, 2010 Share Posted September 28, 2010 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>'; Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted September 28, 2010 Share Posted September 28, 2010 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 Quote Link to comment Share on other sites More sharing options...
jarv Posted September 28, 2010 Author Share Posted September 28, 2010 thanks, yes my code was very untidy! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.