Hello,

Can anyone help me fix this error?

step_3.php

echo '<option value="'.$_SESSION['application']['year'][$i].'"'
                .if($y = $_SESSION['application']['year'][$i]).{'"selected"; >'}.$y.'</option>';

Parse error: syntax error, unexpected 'if' (T_IF) in C:\xampp\htdocs\pergas-responsive\include\ars_application_submission_step_3.php on line 125

You... Have an unexpected if.. You can't concat with a logical step like you are doing... And if you read your code closely you will see you are not actually doing a logical operation at all, as there is no outcome.

Instead of doing dot notation to concat, try writing it the long way and see where all your errors are...

To do a logical concat like you expect you will need to use a ternary logical statement.

Member Avatar for diafol

Use ternery syntax to do this.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.