PHP Developers Network
http://forums.devnetwork.net/

Why Is The Closing Bracket Black ?
http://forums.devnetwork.net/viewtopic.php?f=19&t=143459
Page 1 of 1

Author:  UniqueIdeaMan [ Fri Mar 17, 2017 8:11 pm ]
Post subject:  Why Is The Closing Bracket Black ?

Howdy,

On my NotePad++, the line at 116 shows the closing bracket of the ELSE black. Really really puzzling!
I know my code is not neat but I will tidy it up based on the feedback I got so far but in the meanwhile my great mind is filled with the question why the line at 116 shows the closing bracket of the ELSE black.

Syntax: [ Download ] [ Hide ]
<html>
<head>
<title>
$user Home Page
</title>
</head>
<body>
<body background=".png">

<?php
session_start&#40;&#41;;
require "conn.php";

/*Check if user is logged-in or not by checking if session is set or not. 
If user is not logged-in then redirect to login page. Else, show user&#39;s account homepage.*/


if&#40;!isset&#40;$_SESSION["user"]&#41;&#41; 
{
    header&#40;"location:login.php"&#41;;
}
else 
{
    $user = $_SESSION["user"];
    $sql = "SELECT * FROM users WHERE Username = &#39;".$user."&#39;";
    $result = $conn->query&#40;$sql&#41;;
    while&#40;$row = mysqli_fetch_assoc&#40;$result&#41;&#41; 
    {
        $db_id = $row["Id"];
        $db_username = $row["Username"];
        $db_forename = $row["Forename"];
        $db_surname = $row["Surname"];
        $db_email = $row["Email"];
        $db_bio = $row["Bio"];
        $db_status = $row["Status"];
    
    
        //Welcome user by name.
        echo "<center>Welcome <b><h2>$db_forename $db_surname!</center>"?></h2></b>|

        <?php
        //Display log-out link.
        echo "<p align=&#39;right&#39;><a href=&#39;logout.php&#39;>$user Log Out</a>";?>|</p><br>
    
        <form method="post" action="">    
        <div class="form-group">
        <center><label>Post Status To Friends:</label>
        <input type="text" placeholder="Post Status To Friends" name="post_status_to_friends" /></center><br>
        <center><button type="submit" class="btn btn-default" name="post_status_to_friends" />Post Status To Friends!</button></center>
        </div>

        <form method="post" action="">
        <div class="form-group">
        <center><label>Post Status To Public:</label>
        <input type="text" placeholder="Post Status To Public" name="post_status_to_public" /></center><br>
        <center><button type="submit" class="btn btn-default" name="post_status_to_public" />Post Status To Public!</button></center>
        </div>
    
        <?php
        //Post User Status To Friends in $user table.
        
        if  &#40;isset&#40;$_POST[&#39;post_status_to_friends&#39;]&#41;&#41;
        {
            $status_to_friends = trim&#40;$_POST["post_status_to_friends"]&#41;;
            $status_to_friends = mysqli_real_escape_string&#40;$conn,$status_to_friends&#41;;
        
            $conn->query&#40;"UPDATE $user SET Status_To_Friends $status_to_friends WHERE Username = &#39;".$user."&#39;"&#41;;
            if&#40;$conn->query&#40;$sql&#41;===TRUE&#41;
            {
                echo "posted status for friends to $user table!";
                $conn->close&#40;&#41;;
                exit&#40;&#41;;
            }
            else    
            {
                echo "posting status for friends to $user table failed!";
                $conn->close&#40;&#41;;
                exit&#40;&#41;;
            }
    
            //Post User Status To Friends in "users" table.
        
            $conn->query&#40;"UPDATE users SET Status_To_Friends $status_to_friends WHERE Username = &#39;".$user."&#39;"&#41;;
            if&#40;$conn->query&#40;$sql&#41;===TRUE&#41;
            {
                echo "posted status for friends to users table!";
                $conn->close&#40;&#41;;
                exit&#40;&#41;;
            }
            else    
            {
                echo "posting status for friends to users table failed!";
                $conn->close&#40;&#41;;
                exit&#40;&#41;;
            }
        
            //Display User Status To Friends. Search for User&#39;s data with $user.
            
            $query = "SELECT * FROM $user WHERE Username = &#39;".$user."&#39;";
            $result = mysqli_query&#40;$conn,$query&#41;;
            $numrows = mysqli_num_rows&#40;$result&#41;;
            if&#40;$numrows = 0&#41;
            {        
                echo "No data!";
                $conn->close&#40;&#41;;
                exit&#40;&#41;;
            }
            else 
            {
                while&#40;$row = mysqli_fetch_assoc&#40;$result&#41;&#41; 
                {      
                    $db_status_to_friends = $row["Status_To_Friends"];
                }
                echo "<br><b>$user Status To Friends:</b><br>
                $db_status_to_friends"
;?><br>
                <br>
            }
    
        <?php
        //Post User Status To Public in $user table.
    
        if  &#40;isset&#40;$_POST[&#39;post_status_to_public&#39;]&#41;&#41;
        {
            $status_to_public = trim&#40;$_POST["post_status_to_public"]&#41;;
            $status_to_public = mysqli_real_escape_string&#40;$conn,$status_to_public&#41;;
        
            $conn->query&#40;"UPDATE $user SET Status_To_Public $status_to_public WHERE Username = &#39;".$user."&#39;"&#41;;
            if&#40;$conn->query&#40;$sql&#41;===TRUE&#41;
            {
                echo "posted status for public to $user table!";
                $conn->close&#40;&#41;;
                exit&#40;&#41;;
            }
            else    
            {
                echo "posting status for public to $user table failed!";
                $conn->close&#40;&#41;;
                exit&#40;&#41;;
            }
    
            //Post User Status To Public in users table.
            $conn->query&#40;"UPDATE users SET Status_To_Public $status_to_public WHERE Username = &#39;".$user."&#39;"&#41;;
            if&#40;$conn->query&#40;$sql&#41;===TRUE&#41;
            {
                echo "posted status for public to users table!";
                $conn->close&#40;&#41;;
                exit&#40;&#41;;
            }
            else    
            {
                echo "posting status for public to users table failed!";
                $conn->close&#40;&#41;;
                exit&#40;&#41;;
            }
    
            //Display User Status To Public. Search for User&#39;s data with $user.
            
            $query = "SELECT * FROM $user WHERE Username = &#39;".$user."&#39;";
            $result = mysqli_query&#40;$conn,$query&#41;;
            $numrows = mysqli_num_rows&#40;$result&#41;;
            if&#40;$numrows = 0&#41;
            {        
                echo "No data!";
                $conn->close&#40;&#41;;
                exit&#40;&#41;;
            }
            else 
            {
                while&#40;$row = mysqli_fetch_assoc&#40;$result&#41;&#41; 
                {      
                    $db_status_to_public = $row["Status_To_Public"];
                }
            echo "<br><b>$user Status To Public:</b><br>
            $db_status_to_public"
;?><br>
            <br>
            <?php 
            }
        }
        
        //Display User Bio.
        echo "<br><b>Bio:</b><br>";
        echo "$db_bio";?><br>
        <br>
        
        <?php 
        //Display User&#39;s Latest View.
        echo "<br><b>Latest View:</b><br>";
        echo "$db_latest_view";?><br>
        <br>

        <?php 
        //Display User&#39;s Latest Viewed Url in iFrame.?>
        <iframe src="<?php $db_latest_view;?>"></iframe>
        <?php     
    }
}
?>

</body>
</html>

Author:  Celauran [ Sun Mar 19, 2017 7:17 am ]
Post subject:  Re: Why Is The Closing Bracket Black ?

UniqueIdeaMan wrote:
why the line at 116 shows the closing bracket of the ELSE black.

Because you have a closing PHP tag on line 114.

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/