/    Sign up×
Community /Pin to ProfileBookmark

parsing over Drop-down Select Box ? Error…dont understand why

I’m not sure if this is the correct section of the forums to ask this…

Anyways. Is there a problem with embedding Drop-down Select Boxes within php? I am making an update script for a particular sql table. ?

Below is a section of the update script/page i would prefer to have…

[code=php]Echo”<form action=’update2.php’ method=’post’ >
<input type=’hidden’ name=’id’ value=’$id’>
KoC Name: <input type=’text’ name=’koc_name’ value=’$koc_name’><br>

Rank: <select name=”dm_rank” size=”1″ value=”Demented”> // line 30
<option value=”Deranged”>Deranged</option>
<option value=”Deviant”>Deviant</option>
<option value=”Derilious”>Derilious</option>
<option value=”Demented”>Demented</option>
<option value=”Maniacal”>Maniacal</option>
</select><br>
Stats Link: <input type=’text’ name=’stats’ value=’$stats’><br>
<input type=’Submit’ value=’Update’>
</form>
</p>”;[/code]

However, it gives the following error…(i have indicated line 30 in the above.)

[QUOTE]

Parse error: parse error, expecting `‘,” or `‘;” in /home/www/baloo.disturbedmortality.com/dmsite/update.php on line 30

[/QUOTE]

The script only works if i breakout of parsing of the php around the Drop-down Select Box.

[code=php]Echo”<form action=’update2.php’ method=’post’ >
<input type=’hidden’ name=’id’ value=’$id’>
KoC Name: <input type=’text’ name=’koc_name’ value=’$koc_name’><br>
“;
?>
Rank: <select name=”dm_rank” size=”1″>
<option value=”Deranged”>Deranged</option>
<option value=”Deviant”>Deviant</option>
<option value=”Derilious”>Derilious</option>
<option value=”Demented”>Demented</option>
<option value=”Maniacal”>Maniacal</option>
</select><br>
<?
Echo”Stats Link: <input type=’text’ name=’stats’ value=’$stats’><br>
<input type=’Submit’ value=’Update’>
</form>
</p>”;[/code]

I dont beleive there is an error anywhere else on the page – as, if i remove the Drop-down Select Box, the form can then be parsed straight through without an error.

Does anyone know what the problem is here? ?

Thank you

Shears ?

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@aussie_girlJul 09.2006 — Your going to have to use the escape character on the double quotes in your select name, because your echo statement starts with double quotes it's expecting the next double quote to be the end and have a semi colon there

[code=php]Echo"<form action='update2.php' method='post' >
<input type='hidden' name='id' value='$id'>
KoC Name: <input type='text' name='koc_name' value='$koc_name'><br>

Rank: <select name="dm_rank" size="1" value="Demented"> // line 30
<option value="Deranged">Deranged</option>
<option value="Deviant">Deviant</option>
<option value="Derilious">Derilious</option>
<option value="Demented">Demented</option>
<option value="Maniacal">Maniacal</option>
</select><br>
Stats Link: <input type='text' name='stats' value='$stats'><br>
<input type='Submit' value='Update'>
</form>
</p>";[/code]
Copy linkTweet thisAlerts:
@ShearsauthorJul 09.2006 — ...and it was something that simple :o Thank you aussie girl ?

Is there any disadvantage to making all the quotes between the two Echo quotes, single quotes, rather than using the escape character with the double quote?

Thank you

Shears ?
Copy linkTweet thisAlerts:
@NogDogJul 09.2006 — Single quotes are fine for HTML attribute values.

Or, you can avoid worrying about internal quotes by using the "heredoc" method of quoting:
[code=php]
echo <<<END
<form action='update2.php' method='post' >
<input type='hidden' name='id' value='$id'>
KoC Name: <input type='text' name='koc_name' value='$koc_name'><br>

Rank: <select name="dm_rank" size="1" value="Demented"> // line 30
<option value="Deranged">Deranged</option>
<option value="Deviant">Deviant</option>
<option value="Derilious">Derilious</option>
<option value="Demented">Demented</option>
<option value="Maniacal">Maniacal</option>
</select><br>
Stats Link: <input type='text' name='stats' value='$stats'><br>
<input type='Submit' value='Update'>
</form>
</p>
END;
// the above line must start in the very first column, no tabs or spaces before it
[/code]
Copy linkTweet thisAlerts:
@aussie_girlJul 09.2006 — I personally use the single quotes, because I'm used to double quotes in HTML, but I don't think it has an advantage or disadvantage just personal preference, try both of them and chose the one that you want..
Copy linkTweet thisAlerts:
@ShearsauthorJul 09.2006 — Thank you ?
×

Success!

Help @Shears spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...