How do I debug this error?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Hamimah
    New Member
    • May 2008
    • 1

    How do I debug this error?

    I'm a beginner and this is my class assignment.
    PHP reports the following error when tried to run the program,
    Parse error: syntax error, unexpected T_IF in C:\xampp\htdocs \untitled.php on line 118.

    How do I debug the error?

    Here's a snippet of the code:

    <p>&nbsp;</p>
    <table width="800" border="1" align="center" bordercolor="#0 00000">

    <tr bgcolor="#DD355 7">
    <th colspan="2" class="style12" scope="col">And our comments for this conversion are as follow: </th>
    </tr>
    <tr>
    <td width="50%"><sp an class="style27" >Great than or equal <?= $greaterthanore qual ?> </span></td>
    <td width="50%">
    <?=
    LINE 118 --> if ($conversion >= $greaterthanore qual)
    {
    echo "<font color=#FF0000>$ comment1</font>";
    }
    else
    {
    echo "$comment1" ;
    }
    ?>

    </td>
    </tr>
    <tr>
    <td><span class="style27" >Between <?= $between1 ?> to <?= $betweeen2 ?> </span></td>
    <td>
    <?=
    if(($conversion >= $between1) and ($converted <= $between2))
    {
    echo "<font color=#FF0000>$ comment2</font>";
    }
    else
    {
    echo "$comment2" ;
    }
    ?>

    </td>
    </tr>
    <tr>
    <td><span class="style27" >Less than or equal <?= $lessthanorequa l ?></span></td>
    <td>
    <?=
    if($conversion <= $lessthanorequa l)
    {
    echo "<font color=#FF0000>$ comment3</font>";
    }
    else
    {
    echo "$comment3" ;
    }
    ?>

    </td>
    </tr>
    </table>
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    When posting please use code tags.
    Revise your code and do so.

    Also, it would be helpful to know what line 118 is.

    The error is that you do this:
    [php]
    <?=
    if( ...
    [/php]
    You cant use that short tag in that situation: <?= is used to echo a variable - nothing else.

    [php]
    <?= $variable?> // works
    <?= if($foo == $bar) ... ?> // wont work.
    [/php]

    Comment

    Working...