I keep getting parse error, unexpected T_STRING

Hello all,

Im studying php but ran into the following prob that i cannot seem to solve

this is my first part of the form and i ran it through the browser to see if all was ok

<?
if (@$saywhich) {
include ("statecapitals.php");
$choice=rand(0,49);
if ($which=='state') {
$state = $states[$choice];
print ("What is the capital of $state?<br>");
print ("<form action='miniquizcheck.php' ");
print ("method='get'>\n");
print ("<input type='text' name='capital'><br>n");
print ("<input type='hidden' name='which'>");
print ("value='$which'>n");
print ("<input type='text' name='choice' ");
print ("<input type='hidden' name='choice'>n");
print ("value='$choice'>n");
print ("<input type='submit' value='Submit answer'>");
print ("</form>n");
?>

I get a parse error on line 13 which is

print ("What is the capital of $state?<br>");

I get no further explanation like missing of quotes or something like that.

Ive tried typing all the code in notepad and also typed it in dreamweaver to do a code check but i cannot find the error.

Can somebody please help me out on this one? probably very simple one or maybe something is misconfigured on my local server?

usually when you get a parse error on a line you need to look above an bleow the actuall line that it gives you. So I see right off hand, this is called to my attention:

[php]<?
$state = $states[$choice];
?>[/php]

I may be wrong, but that doesn’t look like proper syntax.

Beleive it needs double (or is it single) quotes - you can figure it out.

<? $state = $states["$choice"]; ?>
Sponsor our Newsletter | Privacy Policy | Terms of Service