show_info accesses the super-global variable $_GET. Open
function show_info($access) {
require_once("../get_photo.php");
$user_id = $_GET['user_id'];
$photolink = getPhotoLink($user_id);
include("../mysql_access.php");
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
Method show_info
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
function show_info($access) {
require_once("../get_photo.php");
$user_id = $_GET['user_id'];
$photolink = getPhotoLink($user_id);
include("../mysql_access.php");
Avoid using undefined variables such as '$db' which will lead to PHP notices. Open
$result = $db->query($sql);
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$db' which will lead to PHP notices. Open
$result = $db->query($sql);
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$db' which will lead to PHP notices. Open
$result = $db->query($sql);
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid unused parameters such as '$access'. Open
function show_info($access) {
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 13 and the first side effect is on line 2. Open
<?php
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "true" but found "True" Open
$active_page = True;
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "false" but found "False" Open
$exec_page = False;
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "true" but found "True" Open
$public_page = True;
- Exclude checks
Line exceeds 120 characters; contains 389 characters Open
$sql = "SELECT firstname, lastname, pledgesem, pledgeyear FROM (SELECT id, firstname, lastname, pledgesem, pledgeyear FROM contact_information UNION DISTINCT SELECT id, firstname, lastname, pledgesem, pledgeyear FROM alumni UNION DISTINCT SELECT id, firstname, lastname, pledgesem, pledgeyear FROM alumni_info WHERE pledgesem<>\"\" AND pledgeyear<>\"\")all_users WHERE id=\"$user_id\";";
- Exclude checks
Line exceeds 120 characters; contains 391 characters Open
$sql = "SELECT big_id, firstname, lastname FROM family_tree LEFT JOIN (SELECT id, firstname, lastname FROM contact_information UNION DISTINCT SELECT id, firstname, lastname FROM alumni UNION DISTINCT SELECT id, firstname, lastname FROM alumni_info WHERE pledgesem<>\"\" AND pledgeyear<>\"\")all_users ON family_tree.big_id=all_users.id WHERE little_id=\"$user_id\" ORDER BY lastname ASC;";
- Exclude checks
Line exceeds 120 characters; contains 394 characters Open
$sql = "SELECT little_id, firstname, lastname FROM family_tree LEFT JOIN (SELECT id, firstname, lastname FROM contact_information UNION DISTINCT SELECT id, firstname, lastname FROM alumni UNION DISTINCT SELECT id, firstname, lastname FROM alumni_info WHERE pledgesem<>\"\" AND pledgeyear<>\"\")all_users ON family_tree.little_id=all_users.id WHERE big_id=\"$user_id\" ORDER BY lastname ASC;";
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
echo "</div><div class=\"small-8 columns\">";
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
echo "</div></div>";
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
$sql = "SELECT little_id, firstname, lastname FROM family_tree LEFT JOIN (SELECT id, firstname, lastname FROM contact_information UNION DISTINCT SELECT id, firstname, lastname FROM alumni UNION DISTINCT SELECT id, firstname, lastname FROM alumni_info WHERE pledgesem<>\"\" AND pledgeyear<>\"\")all_users ON family_tree.little_id=all_users.id WHERE big_id=\"$user_id\" ORDER BY lastname ASC;";
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
echo "</div>";
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
$sql = "SELECT big_id, firstname, lastname FROM family_tree LEFT JOIN (SELECT id, firstname, lastname FROM contact_information UNION DISTINCT SELECT id, firstname, lastname FROM alumni UNION DISTINCT SELECT id, firstname, lastname FROM alumni_info WHERE pledgesem<>\"\" AND pledgeyear<>\"\")all_users ON family_tree.big_id=all_users.id WHERE little_id=\"$user_id\" ORDER BY lastname ASC;";
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
$result = $db->query($sql);
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
echo "<div class=\"small-3 columns end text-center\"><div class=\"biglittle\" id=\"bl" . $row['little_id'] . "\">";
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
echo "<div class=\"row\"><div class=\"small-4 columns\">";
- Exclude checks
Opening brace should be on a new line Open
function show_active() {
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
$sql = "SELECT firstname, lastname, pledgesem, pledgeyear FROM (SELECT id, firstname, lastname, pledgesem, pledgeyear FROM contact_information UNION DISTINCT SELECT id, firstname, lastname, pledgesem, pledgeyear FROM alumni UNION DISTINCT SELECT id, firstname, lastname, pledgesem, pledgeyear FROM alumni_info WHERE pledgesem<>\"\" AND pledgeyear<>\"\")all_users WHERE id=\"$user_id\";";
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
$result = $db->query($sql);
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
}
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
echo "<div class=\"small-12 columns\"><h5>Littles</h5>";
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
echo "<img src=\"" . getPhotoLink($row['little_id']) . "\"><br>";
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
echo "<p>Pledged: {$row['pledgesem']} {$row['pledgeyear']}</p></div>";
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
show_info("public");
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
echo "</div>";
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
echo "</div></div>";
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
require_once("../get_photo.php");
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
$user_id = $_GET['user_id'];
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
echo "<div class=\"small-12 columns\"><h5>Bigs</h5>";
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
$photolink = getPhotoLink($user_id);
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
echo "<img src=\"$photolink\">";
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
echo "<div class=\"small-3 columns end text-center\"><div class=\"biglittle\" id=\"bl" . $row['big_id'] . "\">";
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
echo "<h4>{$row['firstname']} {$row['lastname']}</h4>\n";
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
show_info("active");
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
die("Unable to determine user_id");
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
include("../mysql_access.php");
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
echo "<p>" . $row['firstname'] . " " . $row['lastname'] . "</p>";
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
while ($row = mysqli_fetch_array($result)) {
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
}
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
echo "<p>" . $row['firstname'] . " " . $row['lastname'] . "</p>";
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
$row = mysqli_fetch_array($result);
- Exclude checks
Opening brace should be on a new line Open
function show_info($access) {
- Exclude checks
Line indented incorrectly; expected 4 spaces, found 2 Open
while ($row = mysqli_fetch_array($result)) {
- Exclude checks
Opening brace should be on a new line Open
function show_public() {
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
$result = $db->query($sql);
- Exclude checks
Line indented incorrectly; expected at least 8 spaces, found 4 Open
echo "<img src=\"" . getPhotoLink($row['big_id']) . "\"><br>";
- Exclude checks
The variable $user_id is not named in camelCase. Open
function show_info($access) {
require_once("../get_photo.php");
$user_id = $_GET['user_id'];
$photolink = getPhotoLink($user_id);
include("../mysql_access.php");
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $user_id is not named in camelCase. Open
function show_info($access) {
require_once("../get_photo.php");
$user_id = $_GET['user_id'];
$photolink = getPhotoLink($user_id);
include("../mysql_access.php");
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $user_id is not named in camelCase. Open
function show_info($access) {
require_once("../get_photo.php");
$user_id = $_GET['user_id'];
$photolink = getPhotoLink($user_id);
include("../mysql_access.php");
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $user_id is not named in camelCase. Open
function show_info($access) {
require_once("../get_photo.php");
$user_id = $_GET['user_id'];
$photolink = getPhotoLink($user_id);
include("../mysql_access.php");
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $user_id is not named in camelCase. Open
function show_info($access) {
require_once("../get_photo.php");
$user_id = $_GET['user_id'];
$photolink = getPhotoLink($user_id);
include("../mysql_access.php");
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}