Benjamin Sanders
Benjamin Sanders

Reputation: 31

For some reason part of this PHP code is being commented out

I was trying to get this code to run but for some reason chrome comments the code out. It seems to be correct syntax to me and one other person.

<div>
                <?php
                    $msg_id = '103'; //Message id
                    $uid = '1'; // Message user id
                    $q = mysqli_query($db,"SELECT like_id FROM message_like WHERE uid_fk='$uid' and msg_id_fk='$msg_id'");
                    if(mysqli_num_rows($q) === 0) {
                        echo '<a href="#" class="like" id="like'. $msg_id . '" title="Unlike" rel="Unlike">Unlike</a>';
                    } else {
                        echo '<a href="#" class="like" id="like'. $msg_id . '" title="Like" rel="Like">Like</a>';
                    }
                ?>
            </div>

Upvotes: 1

Views: 80

Answers (1)

julian soro
julian soro

Reputation: 5228

You are asking why the browser, a client-side application, is commenting out PHP, a server-side language. You need to install a server like Apache or nginx. If you are a total beginner, try the XAMPP project to get a server on your desktop. XAMPP is cross-platform, so it will run on your OS.

https://www.apachefriends.org/index.html

Upvotes: 1

Related Questions