Attributes construct error

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

dcasteve
New php-forum User
New php-forum User
Posts: 4
Joined: Tue Aug 02, 2011 2:16 pm

Attributes construct error

Postby dcasteve » Fri Feb 08, 2013 3:38 pm

Hi everyone....can't seem to figure this one out. I don't see what is wrong with line 220....I've tried removing the spaces thereby running everything together, tried removing some of the spaces (i.e. the space between "2011" and <?php) among various other combinations of spacing, still get these errors.....don't see any unclosed/unresolved ending tags.....

220 attributes construct error [XHTML 1.0 Strict]
220 Couldn't find end of Start Tag option line 220 [XHTML 1.0 Strict]
220 Opening and Ending tag mismatch: select line 218 and option [XHTML 1.0 Strict]
222 Opening and Ending tag mismatch: div line 216 and select [XHTML 1.0 Strict]

Here is the code:

216 <div class="content_onecolumn">
217 <label for="report_year" class="long"><span style="font-weight:bold">1.</span> Report for Year:</label>
218 <select name="report_year" id="report_year" class="selectTwo">
219 <option value="" selected="selected">*Select the Year*</option>
220 <option value="2011" <?php if($_POST['report_year'] == 2011) echo 'selected';?>>2011</option>
221 </select>
222 </div>

Any ideas? Thanks - Steve

armandohg
New php-forum User
New php-forum User
Posts: 3
Joined: Sun Feb 10, 2013 10:23 pm

Re: Attributes construct error

Postby armandohg » Sun Feb 10, 2013 10:26 pm

maybe try modifying the line 220 to this:
220 <option value="2011" <?php if($_POST['report_year'] == 2011) echo 'selected="selected"';?>>2011</option>


see if that works.

dcasteve
New php-forum User
New php-forum User
Posts: 4
Joined: Tue Aug 02, 2011 2:16 pm

Re: Attributes construct error

Postby dcasteve » Mon Feb 11, 2013 4:18 pm

Hi armandohg....thanks for the reply. Tried that and I still got the same error....actually tried all of the following:

Tried this next....
<option value="2011" <?php if($_POST['report_year'] == 2011) { echo 'selected="selected"'; } ?>>2011</option>

Then this....
<option value="2011" <?php if($_POST['report_year'] == 2011) { echo "selected='selected'"; } ?>>2011</option>

Then this....
<option value="2011" <?php if($_POST['report_year'] == 2011) echo 'selected="selected"'; ?>>2011</option>

Lastly this....
<option value="2011" <?php if($_POST['report_year'] == 2011) echo "selected='selected'"; ?>>2011</option>


Not sure where to go from here!

armandohg
New php-forum User
New php-forum User
Posts: 3
Joined: Sun Feb 10, 2013 10:23 pm

Re: Attributes construct error

Postby armandohg » Mon Feb 11, 2013 6:09 pm

Just for testing porpuses I would remove the PHP code and set the 'selected' attribute directly as in:

<option value="2011" selected="selected">2011</option>

please let me know how this works?

the next step depends on the result of this

seandisanti
php-forum Fan User
php-forum Fan User
Posts: 838
Joined: Mon Oct 01, 2012 12:32 pm

Re: Attributes construct error

Postby seandisanti » Mon Feb 11, 2013 11:07 pm

i typically use a ternary operator in situations like this. try:

Code: Select all

<option value="2011" <?php echo ($_POST['report_year']==2011)?'selected="selected":'' ?>>2011</option>


Return to “PHP coding => General”

Who is online

Users browsing this forum: Google [Bot] and 4 guests

cron