missing a quote somewhere T_String error
This is driving me crazy i know its a simple error but either i added or left out a quote something
echo "<option ". ($data['language'] == "" ? 'selected=selected>-- Select --</option>' : 'value=$dat开发者_高级运维a['language'] selected=selected'");
Use
echo "<option ". ($data['language'] == "" ? "selected=selected>-- Select --</option>" : "value=".$data['language']." selected=selected");
There was an inconsistant use of quotes/inline variable inclusion (so there was a ' where there should be a ")
You can't do variable interpolation in single quotes, and especially when using single quotes as the delimiter.
echo "<option ". ($data['language'] == "" ? 'selected=selected>-- Select --</option>' : 'value=' . $data['language'] . ' selected=selected'");
Change:
'value=$data['language'] selected=selected'
Into:
'value="'.$data['language'].'" selected=selected'
echo "<option "
. ($data['language'] == ""
? 'selected=selected>-- Select --</option>' :
'value=$data['language'] selected=selected'" //< This line
);
As you can see your using the same quotes as the selection from the $data array so you need to do:
echo "<option " . ($data['language'] == "") ? 'selected=selected>-- Select --</option>' : "value=\"" . $data['language'] . "\" \"selected=selected\"" );
a better solution would be:
if($data['language'] == "")
{
echo '<option selected=selected>-- Select --</option>';
}else
{
echo '<option selected=selected value="' . $data['language'] . '">-- Select --</option>';
}
echo "<option ". ($data['language'] == "" ? "selected=selected>-- Select --</option>" : "value='".$data['language'] . "' selected=selected");
精彩评论