<? Computer Bugs ?>

 

Bugs, Errors, Errata, and other Anomalies Study together


We'll use this page to identify common errors made, and how to address them!

We'll also identify 'bugs' and errors in the documents we'll use to build our application, and what to do when you find them.

If it's bugging you, we'll try to address it here!

 

Bug: Categories in my Nav

Error Message: None. But how do we add the 'categories' concept into my navigation? I want the categories to show up as links on every page.

Date/Status: 7/27/2008

Handout: categories

Files effected: categories.php, headerINC.php

Description: The categories page becomes the entry point of the application, replacing the list page. On the categories page there are links to all of the lists of items available. Can't we add this to our navigation? How would this be done?

Remedy: Build your categories page in the usual manner, then add the 'categories' database plumbing to the left nav, so they show up as links in your vertical navigation. Be sure to build the categories page first, so you know all is working, then move it into the headerINC.php file, so it appears on every page.

Comment: Be sure to add categories only to the left nav of your include files. Once we build an administrative interface where your admins can add categories, having too many would blow out your navigation. Make sure categories are only part of a vertical navigation system.


Bug: ' -=' and other combination operators are difficult to understand

Bug: Include file errors

Error Message: include_once(include/utilINC.php) [function.include-once]: failed to open stream: No such file or directory in /home/classes/horsey01/public_html/muffinlist.php on line 14

Date/Status: 7/27/2008

Handout: several

Files effected: any include files

Description: PHP kicks back an odd looking error (see above) when referencing an include file. PHP is trying to explain it can't find the file where we told it to look.

Remedy: Double check to make sure the included file was uploaded to the correct folder, that it's file name is in perfect case (upper/lower) and the path is the same as referenced.

Comment: Be sure to make sure all files are uploaded from a handout before trying to run the program. If you changed the path to your include files from the word include, (used in our examples) be prepared to change it in every handout!


Bug: ' -=' and other combination operators are difficult to understand

Error Message: none. Not knowing how they operate makes us tend to ignore using these operators.

Date/Status: 7/10/2008

Handout: none

Files effected: none specifically

Description: The -= combination doesn't mean "less than or equal to" (I don't think!?). Does it mean "either subtract or make equal"? The mind boggles!

Remedy: Combination operators, like .=, +=, -= and the rest help us assign data, not compare it.

The illusion here is the equals sign does not mean comparison, rather assignment.

So, if we say:

$myVar = 3;

We are not comparing these values, we are assigning the number 3 to the variable named $myVar.

When we use the -= operator, we are subtracting the value from the right side of the equation, from the total on the left, and storing the final value in the left side of the operator.

So, to take our previous equation further:

$myVar = 3;
$myVar -= 2;


The value left in $myVar is now 1. To see this in action, you can always place the values in a tiny php page, for example:

<?
$myVar = 3;
$myVar -= 2;
print $myVar;
?>

The following two statements are equivalents:

$myVar -=2;
$myVar = $myVar - 2;

Remember you can use this combination operator for addition, subtraction, multiplication, and even (and most frequently) concatenation! (connecting strings):

$myVar .= " add this to the existing string!"; //concatenation adds a new piece of a string to the existing string

Comment: We'll see this example in code produced by others frequently, so the sooner we become comfortable with this oddity, the better!

 
Print this Page Back To Top

© 2002- 2026 newMANIC INC, All rights reserved