dimanche 25 février 2018

if statement - unexpected 'else' (T_ELSE)

I'm making this comment section page, but i'm getting this error: syntax error, unexpected 'else' (T_ELSE) on line 33

I'm trying to solve this error for about an hour, and i can't find the solution..

Here it is my code :

    <?php 
session_start();
$_SESSION['user'] = "Admin";

function get_total(){
    require 'connect.php';
    $result = mysqli_query($conn, "SELECT * from parents order by date desc");
    $row_cnt = mysqli_num_rows($result);
    echo '<h1>Comentários ('.$row_cnt.')</h1>';
}

function get_comments(){
    require 'connect.php';
    $result = mysqli_query($conn, "SELECT * from parents order by date desc");
    $row_cnt = mysqli_num_rows($result);

    foreach ($result as $item) {
        $date = new dateTime($item['date']);
        $date = date_format($date, 'M j, Y | H:i:s');
        $user = $item['user'];
        $get_comment = $item['text'];
        $par_code = $item['code'];

        echo '<div class="comment" id="'.$par_code.'">'
            .'<p class = "user">'.$user.'</p>&nbsp;'
            .'<p class = "comment-text">'.$comment.'</p>'
            .'<a class = "link-reply" id="reply" name="'.$par_code.'">Reply</a>';

            $chi_result = myqsli_query($conn, "SELECT * FROM `children` WHERE `par_code` = '$par_code' ORDER BY `date` DESC");
            $chi_cnt= mysqli_num_rows($chi_result);

            if ($chi_cnt == 0) 
                { else{
                    echo '<a class ="link-reply" id="children" name="'-$par_code.'"><span id="tog_text">Respostas</span> ('.$chi_cnt.')</a>'
                    .'<div class="child-comments" id="C-'.$par_code.'">';
                foreach ($chi_cnt as $com) {
                    $chi_date = new dateTime($com['date']);
                    $chi_date = date_format($chi_date, 'M j, Y | H:i:s');
                    $chi_user = $com['user'];
                    $chi_com = $com['text'];
                    $chi_par = $com['par_code'];

                    echo '<div class="child" id="'.$par_code' -C">'
                            .'<p class="user">'.$chi_user.'</p>&nbsp;'
                            .'<p class="time">'.$chi_date.'</p>'
                            .'<p class="comment-text">'.$chi_com.'</p>'
                            .'</div>';
                }
                echo '</div>';
            }
            echo '</div>';
    }
}
      ?>

i think it is a stupid error, and sorry for bad english!!

Aucun commentaire:

Enregistrer un commentaire