开发者

Syntax Error, unexpected $end [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 9 years ago.

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 li开发者_JS百科ne 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.


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.


Маке

<?php}?>

to

<?php } ?>

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


The error message “unexpected $end” means that one or more blocks are not properly closed like when a closing } is missing. But your code seems to be correct. You should take a look at your other control structures and see if everything is at its place.


Edit    I think I got it: Though your code seems to be syntactically correct, the <?php}?> is what the parser chokes on. Make it a <?php }?> and it should work.


you did not close the while properly try :

<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 endwhile; ?>

</select>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜