Click here to Skip to main content
15,070,613 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
My php code isn't working when I try to load the page in the browser it doesn't display anything

What I have tried:

PHP
<?php
$code ="";
$code.='<style type="text/css">
    
    body {
    overflow-x: hidden !important;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: #212529;
    text-align: left;
    background-color: #fff;
}

body {
    display: block;
    margin: 8px;
}

.right {
    float: right;
}

.center {
    float: center;
    text-align: center;
    
}

.pd {
    padding-top: 50px;
}
.cl{
    color: red;
}

table {
  font-family: arial, sans-serif;
  border-collapse: collapse;
  width: 100%;
}

td, th {
  border: 1px solid #dddddd;
  text-align: left;
  padding: 8px;
}

tr:nth-child(even) {
  background-color: #dddddd;
}

.size img {
    height: 40%;
    width: 40%;
}

.red {
    color: red;
    font-size: 16px;
}

.ft {
    font-size: 16px;
}

.pt {
    padding-top: 14px;
}
    
    table tr#ROW1 {
        background-color: #99cc90;
    }

    table tr#ROW2 {
        background-color: white;
    }

    table tr#ROW3 {
        background-color: #eb3737;
    }
    table tr#ROW4 {
        background-color: #b7b7b7;
    }
  

</style>';

$code.='<body style="background-color: azure; ">';

    $code.='<section class="container" style="padding-left: 110px; padding-right: 110px; padding-bottom: 20px;">';
        $code.='<div style="padding-top: 20px;">';
            $code.='<p class="right"> URA STEER Cohort B <br>
                 HENERY K. BYENKYA <br> 28 Aril 2019
            </p>';
        $code.='</div>';
        $code.='<br>
        <br>
        <br>';

        $code.='<div class="pd">';
            $code.='<h3 class="cl"> LEADERSHIP ASSESSMENT REPORT </h3>';
            $code.='<div>';
                $code.='<div class="size">
                    <img class="size" src="images/steer.jpg" />
                </div>';
                $code.='<p>Ken Blanchard says that "Feedback is the breakfast for champions." Leaders need
                    feedback on their performance to develop. This report contains detailed, summary and
                    comparative information on how others perceive you as a leader. The foundation of this
                    assessment is a set of 40 behaviors that are closely associated with leadership success for
                    leaders at the supervisor level. It outlines your proficiency against 40 behaviours tied to
                    eight elements of leadership that are most aligned to the four dimensions of skills and
                    competences covered in the STEER program (Foundations of Leadership & Management;
                    Self Leadership; Leading Others and Leading at the Next Level). Essentially, those that you
                    selected as observers have indicated how frequently they see you engaging in these
                    behaviors. They have also provided commentary on how you have positively influenced
                    them and others, as well as how you might increase your leadership effectiveness in the
                    future. All of this is very valuable information as you consider how you can develop the
                    perspectives, competencies and approaches that will increase your effectiveness as a
                    leader. The good news is that becoming a great leader is within the grasp of all of us.</p>';
            $code.='</div>';
            $code.='<div class="row">';
                $code.='<div class="col-md-6">';
                    $code.='<p>
Posted
Updated 18-Sep-19 10:18am
v2
Comments
F-ES Sitecore 18-Sep-19 11:09am
   
You wrote all that code in one go without testing that it worked? If not go back to your last update that worked and what you did after that is what is breaking things. Or if this isn't your code at all then start with a blank page and add a little of the code, and keep adding more and more code until it stops working, and again the last thing you added is what broke it.
OriginalGriff 18-Sep-19 11:10am
   
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with. So we have no idea what you have tried to get it working, what your debugger shows is happening, any error messages that appear, ...

Use the "Improve question" widget to edit your question and provide better information.
ZurdoDev 18-Sep-19 11:22am
   
Check your console in your browser. You likely have a syntax issue. But you need to debug this.

Very nice, however you forgot the essential line
echo $code;
at the very end

:)
   
Amazing. You assign all of the HTML into the variable $code, but for someone is displays nothing.
Did you perhaps forget to echo() that variable out onto the page?
   
Quote:
My php code isn't working when I try to load the page in the browser it doesn't display anything

Your code do not behave the way you expect, or you don't understand why !

There is an almost universal solution: Run your code on debugger step by step, inspect variables.
The debugger is here to show you what your code is doing and your task is to compare with what it should do.
There is no magic in the debugger, it don't know what your code is supposed to do, it don't find bugs, it just help you to by showing you what is going on. When the code don't do what is expected, you are close to a bug.
To see what your code is doing: Just set a breakpoint and see your code performing, the debugger allow you to execute lines 1 by 1 and to inspect variables as it execute.

Debugger - Wikipedia, the free encyclopedia[^]

Mastering Debugging in Visual Studio 2010 - A Beginner's Guide[^]
Basic Debugging with Visual Studio 2010 - YouTube[^]

phpdbg | php debugger[^]
Debugging techniques for PHP programmers[^]

The debugger is here to only show you what your code is doing and your task is to compare with what it should do.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900