#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2017
    Posts
    318
    Rep Power
    1

    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.

    PHP Code:
    <html>
    <head>
    <title>
    $user Home Page
    </title>
    </head>
    <body>
    <body background=".png">

    <?php
    session_start
    ();
    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's account homepage.*/

    if(!isset($_SESSION["user"])) 
    {
        header("location:login.php");
    }
    else 
    {
        $user $_SESSION["user"];
        $sql "SELECT * FROM users WHERE Username = '".$user."'";
        $result $conn->query($sql);
        while($row mysqli_fetch_assoc($result)) 
        
    {
            $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='right'><a href='logout.php'>$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  
    (isset($_POST['post_status_to_friends']))
            {
                $status_to_friends trim($_POST["post_status_to_friends"]);
                $status_to_friends mysqli_real_escape_string($conn,$status_to_friends);
            
                $conn
    ->query("UPDATE $user SET Status_To_Friends $status_to_friends WHERE Username = '".$user."'");
                if($conn->query($sql)===TRUE)
                {
                    echo "posted status for friends to $user table!";
                    $conn->close();
                    exit();
                }
                else    
                
    {
                    echo "posting status for friends to $user table failed!";
                    $conn->close();
                    exit();
                }
        
                
    //Post User Status To Friends in "users" table.
            
                $conn
    ->query("UPDATE users SET Status_To_Friends $status_to_friends WHERE Username = '".$user."'");
                if($conn->query($sql)===TRUE)
                {
                    echo "posted status for friends to users table!";
                    $conn->close();
                    exit();
                }
                else    
                
    {
                    echo "posting status for friends to users table failed!";
                    $conn->close();
                    exit();
                }
            
                
    //Display User Status To Friends. Search for User's data with $user.
                
                $query 
    "SELECT * FROM $user WHERE Username = '".$user."'";
                $result mysqli_query($conn,$query);
                $numrows mysqli_num_rows($result);
                if($numrows 0)
                {        
                    echo 
    "No data!";
                    $conn->close();
                    exit();
                }
                else 
                
    {
                    while($row mysqli_fetch_assoc($result)) 
                    
    {      
                        $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  
    (isset($_POST['post_status_to_public']))
            {
                $status_to_public trim($_POST["post_status_to_public"]);
                $status_to_public mysqli_real_escape_string($conn,$status_to_public);
            
                $conn
    ->query("UPDATE $user SET Status_To_Public $status_to_public WHERE Username = '".$user."'");
                if($conn->query($sql)===TRUE)
                {
                    echo "posted status for public to $user table!";
                    $conn->close();
                    exit();
                }
                else    
                
    {
                    echo "posting status for public to $user table failed!";
                    $conn->close();
                    exit();
                }
        
                
    //Post User Status To Public in users table.
                $conn->query("UPDATE users SET Status_To_Public $status_to_public WHERE Username = '".$user."'");
                if($conn->query($sql)===TRUE)
                {
                    echo "posted status for public to users table!";
                    $conn->close();
                    exit();
                }
                else    
                
    {
                    echo "posting status for public to users table failed!";
                    $conn->close();
                    exit();
                }
        
                
    //Display User Status To Public. Search for User's data with $user.
                
                $query 
    "SELECT * FROM $user WHERE Username = '".$user."'";
                $result mysqli_query($conn,$query);
                $numrows mysqli_num_rows($result);
                if($numrows 0)
                {        
                    echo 
    "No data!";
                    $conn->close();
                    exit();
                }
                else 
                
    {
                    while($row mysqli_fetch_assoc($result)) 
                    
    {      
                        $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's Latest View.
            echo "<br><b>Latest View:</b><br>";
            echo "$db_latest_view";?><br>
            <br>

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

    </body>
    </html>
  2. #2
  3. Lord of the Dance
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Oct 2003
    Posts
    4,131
    Rep Power
    2011
    Would be nice if you had marked location of line 116.

    You close php script before the two br-tags, but the php start tag is placed bekow the closing bracket, in stead of above.
    Last edited by MrFujin; March 17th, 2017 at 10:06 PM.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2017
    Posts
    318
    Rep Power
    1

    Question


    Originally Posted by MrFujin
    Would be nice if you had marked location of line 116.

    You close php script before the two br-tags, but the php start tag is placed bekow the closing bracket, in stead of above.
    I did the same on line 168-178 ELSE but the closing tag is not black there. Check my old code above for confirmation.
    However heeding your advice, the error is gone.
    Now, I need to get the iframe to show the url (url is value from the variable: $latest_view).
    $latest_view gets it's value from the tbl row (pos: 0) column: Latest_View.
    Currently, the row holds this url as it's entry:

    https://www.youtube.com/playlist?lis...NcNTzUgYg_yG-U

    I tried:
    <iframe src="<?php echo $db_latest_view;?>">
    <iframe src="<?php echo "$db_latest_view";?>">
    <iframe src="<?php echo \"$db_latest_view\";?>">

    But no luck! Url fails to load in iframe.

    Here is the latest updated code:

    PHP Code:
    <html>
    <head>
    <title>
    <?php
    $user?>
     Home Page
    </title>
    </head>
    <body>
    <body background=".png">

    <?php
    session_start
    ();
    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's account homepage.*/

    if(!isset($_SESSION["user"])) 
    {
        
    header("location:login.php");
    }
    else 
    {
        
    $user $_SESSION["user"];
        
    $sql "SELECT * FROM users WHERE Username = '".$user."'";
        
    $result $conn->query($sql);
        while(
    $row mysqli_fetch_assoc($result)) 
        {
            
    $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_to_friends $row["Status_To_Friends"];
            
    $db_status_to_public $row["Status_To_Public"];
            
    $db_latest_view $row["Latest_View"];
        
        
            
    //Welcome user by name.
            
    echo "<center>Welcome <b><h2>$db_forename $db_surname!</center>"?></h2></b>|

            <?php
            
    //Display log-out link.
            
    echo "<p align='right'><a href='logout.php'>$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  (isset($_POST['post_status_to_friends']))
            {
                
    $status_to_friends trim($_POST["post_status_to_friends"]);
                
    $status_to_friends mysqli_real_escape_string($conn,$status_to_friends);
            
                
    $conn->query("UPDATE $user SET Status_To_Friends $status_to_friends WHERE Username = '".$user."'");
                if(
    $conn->query($sql)===TRUE)
                {
                    echo 
    "posted status for friends to $user table!";
                    
    $conn->close();
                    exit();
                }
                else    
                {
                    echo 
    "posting status for friends to $user table failed!";
                    
    $conn->close();
                    exit();
                }
        
                
    //Post User Status To Friends in "users" table.
            
                
    $conn->query("UPDATE users SET Status_To_Friends $status_to_friends WHERE Username = '".$user."'");
                if(
    $conn->query($sql)===TRUE)
                {
                    echo 
    "posted status for friends to users table!";
                    
    $conn->close();
                    exit();
                }
                else    
                {
                    echo 
    "posting status for friends to users table failed!";
                    
    $conn->close();
                    exit();
                }
            
                
    //Display User Status To Friends. Search for User's data with $user.
                
                
    $query "SELECT * FROM $user WHERE Username = '".$user."'";
                
    $result mysqli_query($conn,$query);
                
    $numrows mysqli_num_rows($result);
                if(
    $numrows 0)
                {        
                    echo 
    "No data!";
                    
    $conn->close();
                    exit();
                }
                else 
                {
                    while(
    $row mysqli_fetch_assoc($result)) 
                    {      
                        
    $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  (isset($_POST['post_status_to_public']))
            {
                
    $status_to_public trim($_POST["post_status_to_public"]);
                
    $status_to_public mysqli_real_escape_string($conn,$status_to_public);
            
                
    $conn->query("UPDATE $user SET Status_To_Public $status_to_public WHERE Username = '".$user."'");
                if(
    $conn->query($sql)===TRUE)
                {
                    echo 
    "posted status for public to $user table!";
                    
    $conn->close();
                    exit();
                }
                else    
                {
                    echo 
    "posting status for public to $user table failed!";
                    
    $conn->close();
                    exit();
                }
        
                
    //Post User Status To Public in users table.
                
    $conn->query("UPDATE users SET Status_To_Public $status_to_public WHERE Username = '".$user."'");
                if(
    $conn->query($sql)===TRUE)
                {
                    echo 
    "posted status for public to users table!";
                    
    $conn->close();
                    exit();
                }
                else    
                {
                    echo 
    "posting status for public to users table failed!";
                    
    $conn->close();
                    exit();
                }
        
                
    //Display User Status To Public. Search for User's data with $user.
                
                
    $query "SELECT * FROM $user WHERE Username = '".$user."'";
                
    $result mysqli_query($conn,$query);
                
    $numrows mysqli_num_rows($result);
                if(
    $numrows 0)
                {        
                    echo 
    "No data!";
                    
    $conn->close();
                    exit();
                }
                else 
                {
                    while(
    $row mysqli_fetch_assoc($result)) 
                    {      
                        
    $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's Latest View.
            
    echo "<br><b>Latest View:</b><br>";
            echo 
    "$db_latest_view";?><br>
            <br>

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

    </body>
    </html>
  6. #4
  7. Wiser? Not exactly.
    Devshed God 2nd Plane (6000 - 6499 posts)

    Join Date
    May 2001
    Location
    Bonita Springs, FL
    Posts
    6,111
    Rep Power
    4103
    Youtube doesn't allow you to iframe it's pages. Check your browsers error console.
    Refused to display 'https://www.youtube.com/playlist?list=PLONQt8bJdq9ayhjJkDsNcNTzUgYg_yG-U' in a frame because it set 'X-Frame-Options' to 'sameorigin'.
    When you echo variables there's no need to put quotes around them. Quotes are only needed when you want to echo a string literal.
    Code:
    echo $db_latest_view; //Preferred
    echo "$db_latest_view"; //Works but unnecessary / confusing; don't do it.
    Recycle your old CD's



    If I helped you out, show some love with some reputation, or tip with Bitcoins to 1N645HfYf63UbcvxajLKiSKpYHAq2Zxud
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2017
    Posts
    318
    Rep Power
    1
    Originally Posted by kicken
    Youtube doesn't allow you to iframe it's pages. Check your browsers error console.


    When you echo variables there's no need to put quotes around them. Quotes are only needed when you want to echo a string literal.
    Code:
    echo $db_latest_view; //Preferred
    echo "$db_latest_view"; //Works but unnecessary / confusing; don't do it.

    Thanks. I will try remembering that.
    Why on earth doesn't this forum have a thumbs-up/LIKE button ? You see what I meant by I can see improvements that can be done on platforms, hence want to learn php to build my own because I am unsatisfied with the current platforms ?
    I mentioned all this here:

    Which Parts Of Php Not To Learn ?

    Anyway, got to head-off to tutorialspoint.com. While I learn php there, at the back of my head, I will be thinking ho to improve the cuurrent features of forums so thread replyers can not only earn THANKS/THUMB-UP but other things too like earn money, credits of some sort which benefits them personally and/or commercially.
    Last edited by UniqueIdeaMan; March 21st, 2017 at 10:07 AM.
  10. #6
  11. Lord of the Dance
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Oct 2003
    Posts
    4,131
    Rep Power
    2011
    Originally Posted by UniqueIdeaMan
    Why on earth doesn't this forum have a thumbs-up/LIKE button
    There is a reputation system on this forum where you can agree/disagree at a specific post.
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2017
    Posts
    3
    Rep Power
    0
    Hello everyone, i want to know, what is
    the closing bracket of the ELSE black.
    What mean "black"? I'm sorry, my english is weak
  14. #8
  15. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Caro, Michigan
    Posts
    14,814
    Rep Power
    4536
    Originally Posted by zehrx
    Hello everyone, i want to know, what is


    What mean "black"? I'm sorry, my english is weak
    He's asking why the code in his editor is not highlighted or color coded the correct way. If the editor recognized line 116 as PHP code, it'd be green or something instead of black.
    -- Cigars, whiskey and wild, wild women. --

IMN logo majestic logo threadwatch logo seochat tools logo