Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Syntax Error, unexpected $end [closed]

Tags:

php

Been trying for hours this php embedding in html but something is wrong as i get a error:

Parse error: syntax error, unexpected $end in C:\Program Files\xampp\htdocs\profile.php on line 678

<select value='$pays' name='pays' id='pays' style='width: 204px;margin-bottom: 5px; outline-width:0;'>
<?php
$result = mysql_query("SELECT pays_az, pays_zz, pays_or FROM in_lays WHERE pays_flush = '1' ORDER BY pays_nom ASC");
while ($row = mysql_fetch_array ($result) )
{  ?>
     <option value="<?php echo $row['dd']; ?>"

     <?php   if($row['dd_id'] == $pays)
     {
        echo 'selected="selected" ' ;
     }
     else
     {
           if($row['dd_id'] == "61")
        {
       echo 'selected="selected"' ;
        }
     }
 ?>><?php echo $row['lala']; ?></option>
<?php}?>

</select>

dont pay attention to the names in the sql request.

like image 921
tetris Avatar asked Mar 20 '26 19:03

tetris


2 Answers

change <?php}?> to <?php } ?>, i think thats the problem (and you should realy try to format your code better, it's a horror to read that.)

EDIT: without changing too much, i would format your code like this:

<select value="<? echo $pays; ?>" name="pays" id="pays" style="width: 204px;margin-bottom: 5px; outline-width:0;">
    <?
    $result = mysql_query("
            SELECT
                pays_az,
                pays_zz,
                pays_or
            FROM
                in_lays
            WHERE
                pays_flush = '1'
            ORDER BY
                pays_nom ASC
            ");
    while($row = mysql_fetch_array($result)){
    ?>
        <option value="<? echo $row['dd']; ?>"
            <?
            if($row['dd_id'] == $pays || $row['dd_id'] == "61"){
                echo ' selected="selected"';
            }
            ?>
        ><? echo $row['lala']; ?></option>
    <?
    }
    ?>
</select>

Note: i used (evil) short php-tags, but you can change that. i write the opening { in the same linne as the if or while-statement and don't use too much spaces (but that depends on personal preference). the important thing is to indent your code to be readable.

like image 153
oezi Avatar answered Mar 23 '26 08:03

oezi


Маке

<?php}?>

to

<?php } ?>

And if in first row $pays a php variable. If yes - please echo it

like image 22
GOsha Avatar answered Mar 23 '26 09:03

GOsha



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!