Errata

Learning PHP and MySQL

Errata for Learning PHP and MySQL

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
Printed Page 21
Item #4

The first sentence in item 4 does not make sense: "Set up PHP to load Apache as a
module." It should be: "Set up Apache to load PHP as a module."

Anonymous   
Printed Page 21
Item #1

The "2" of php5apache2.dll refers to the version number of apache that you have downloaded.
If you are downloading v.2.2, make sure you grab file php5apache2_2

Anonymous   
Printed Page 22
Figure 2-11

If you have downloaded version 2.2 of apache, then you will need to use
"LoadModule php5_module c:/php/php5apache2_2.dll"

Anonymous   
Printed Page 22
Figure 2-11

This is for Windows XP. When I inserted the "LoadModule php5_module
C:/php/php5apache2.dll" line in httpd.conf as indicated in Figure 2-11, and then ran
Test Configuration, I got an error that said the "specified module could not be
found." I believe I followed all the steps leading up to this step, and I do not know
what I might have done wrong.

Anonymous   
Printed Page 22
1st illustration

Your errata says:

Anonymous   
Printed Page 22

For Step 5, this line should be added, it was highlighted but not explained:
add this line: LoadModule php5_module c:/php/php5apache2.dll

to the Notepad file underneath:
# LoadModule foo_module modules/mod_foo.so
#

Therefore, the Text Editor file should read:
# LoadModule foo_module modules/mod_foo.so
#
LoadModule php5_module c:/php/php5apache2.dll

Must be LoadModule php5_module c:/php/php5apache2_2.dll not:
LoadModule php5_module c:/php/php5apache2.dll

Anonymous   
Printed Page 23
Tip at foot of page

The "tip" at the foot of the page is not especially useful (and with older versions of OS X is INCORRECT).

For OS x 10.4 it would be useful to identify that the httpd.conf file can be found at /etc/httpd/httpd.conf.

For OS x 10.2 the httpd.conf file is found at the same location but there is an additional block (which is already in the conf file in OS X 10.4) which needs to be added to httpd.conf, mostly anywhere near the end of the httpd.conf file will be OK, as long as it is after the two lines which you've just uncommented "LoadModule PHP4..." and "AddModule mod_php4.c" as follows;

<IfModule mod_php4.c>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
<IfModule mod_dir.c>
DirectoryIndex index.html index.php
</IfModule>
</IfModule>

Without this block no .php or .phps files can be processed as PHP.

(I've no idea whether this is already in OS X 10.3 or not, it's simple enough to find, this block will probably be almost at the end of the httpd.conf file if present).

It might also be useful to state that the DocumentRoot can also be set within httpd.conf and that OS X is shipped with a default setting for DocumentRoot of
/library/webserver/documents
(in both 10.2 and 10.4). This is the location from where "filename" would be accessed on the server from a web browser at httpd://127.0.0.1/filename. (The term "DocumentRoot" might be a nice thing to have in the book's index, too)! This is presumably the equivalent of the Windows instructions referring to htdocs, in step 2 at the foot of page 22.

After changing the httpd.conf file, restart Apache by either disabling and re-enabling Personal File Sharing, (from the System Preferences -> Sharing -> Personal File Sharing button) or alternatively from the Terminal, using the following command;

apachectl restart

Now you have PHP running!

Anonymous   
Printed Page 34
Section missing information

The section starts out referring to creating html pages without clarifying the important point that php code is saved in files named "file.php" and not "file.htm". It reads as if php code is embedded in html files, and it isn't until the bottom of page 36, when "example.php" is referenced that you have any indication otherwise. To be honest having just re-read the section I still don't know if it's a universal truth that all php code is saved in files named with a php extension or not.

Suggested future revision: inclusion of a file name with examples

Anonymous   
Printed Page 34
Example 3-2

"<?php" and "?>" are missing. Tried several times, got frustrated, and then found the error. It is really irresponsible for the authors to make such errors. I should not have bought this book.

<html>
<head>
<title>Hello World
</title>
</head>
<body>
<?php <- missing
echo ("<p>Now I have something to say!</p>");
?> <- missing
</body>
</html>

Anonymous   
Printed Page 39
Fig 3-3

mixup of the capitalisation of $Age and $age (I'm a beginner, but this seems so to me?)

Anonymous   
Printed Page 53
Paragraph preceding Example 3-25

The sentence "If you are using that variable in a test, you'll see the current value before the change." probably should read "If you are using that variable in a test, you'll see the new value after the change.", as it refers to pre-increment and pre-decrement operators.

Anonymous   
Printed Page 58
Last but one paragraph

The word "don't" should be removed from "Because the strings don't contain simple numbers, an expression that is converted without errors...".

Anonymous   
Printed Page 60
Example 4-4. Order of precedence

2 + 4 - 5 == 1;
4 - 5 + 2 == 1;

4 * 5 / 2 == 10;
5 / 2 * 4 == 10;

2 + 4 - 5 == 1;
4 - 5 + 2 == 1;

4 * 5 / 2 == 10;
5 / 2 * 4 == 10;

The example appears to repeat for no reason and there's an extra space between '5'
and '=='

Anonymous   
Printed Page 64
Conditionals section at bottom of page

The second bullet item is 'switch' but in the first paragraph of p65 it says 'PHP
also supports a conditional called a switch statement.'

But then in the last paragraph (p65) is says 'We haven't talked about the second
bullet point, isset, yet.'

i.e. the second bullet point (p64) should have been 'isset' not 'switch'

Anonymous   
Printed Page 67
1st paragraph

$user_name should be $username.

Anonymous   
Printed Page 69
Example 4-11

Extraneous line: echo "Perform actions for shipping.<br>"; and closing curly brace
when there is no opening curly brace.

Script execution fails with error "Parse error: syntax error, unexpected '}'"

Anonymous   
Printed Page 97
Example 5-21 outputs

spacing off.
should be
Guten Tag World!Guten Tag World!

Anonymous   
Printed Page 100
1st paragraph

In the sentence "For instance, if you use a numeric array to store four elements and let PHP pick the number index values, the last value is stored under the index value of 4." the '4' should be replaced with '3'.

Anonymous   
Printed Page 119
Table 7-2

The description of Table 7-2 is "The user purchases table after any normalization."
It should probably be "The user purchases table before any normalization."

Anonymous   
Printed Page 124
chapter 7

You jump right into creating tables without creating a database to begin with First the user must login with priviledges, then from the mysql command line, CREATE DATABASE books. Then the user must use the database : USE DATABASE books. Otherwise you get errors. I am just starting out, was mystified by this until I did a web search. Seems like a big ommission, since stylistically you seem to be catering to someone who has no clue how mySQL works.

Anonymous   
Printed Page 126
After "As long as there are no errors..."

Line 12 should have "ES)2,1" removed.

Line 13 should have ","Aaron Webber";" removed.

Anonymous   
Printed Page 130
1st paragraph

The paragraph says: "It also knows not to display title_id twice and not to display
the author_id for author..". However, the example output shows that the author_id IS
displayed.

Anonymous   
Printed Page 136
Last paragraph.

The last paragraph should read:

The default databases that are present after an install are: (1) information_schema; (2) mysql; and (3) test.

Anonymous   
Printed Page 138
Starting at "Table Manipulation"

The last sentence of the first section reads, "Creating tables is an important
concept, so that is where we are headed!"

Then the next paragraph talks about manipulating the all ready created table. Nothing
about creating a table. After a little snooping I found some mention of table
creationg back on page 124. It seems all goofed up to me.

Anonymous   
Printed Page 171
Example 9-5, Assign the query

From June 2006 printing:

The line of code reads as follows:

$query = "SELECT * FROM 'books' NATURAL JOIN 'authors'";

Should read:

$query = "SELECT * FROM books NATURAL JOIN authors";

Table names in queries aren't quoted, so single quotes around table names shouldn't be used.

Anonymous  Aug 04, 2008 
Printed Page 183
code example

I'm starting to agree with the statement by the single customer reviewer that this
book is very poorly edited: there is something very very wrong with the code on page
183. First of all, I believe everything inside the page's only set of curly braces
needs to be preceded by "echo" or "print"...as it is, it appears to just be a string
literal that nothing is done with, and therefore it dies on the vine. Also, the -if-
condition ought to be
if ($search == NULL)
because you want to display the form if the user has not yet entered input, right?
Furthermore, there is no -else- to govern what happens if they HAVE entered input.
The sample output in Figure 10-2 on the following page has no way of ever appearing
with the code as it stands.

Anonymous   
Printed Page 183
Example 10-2

If you copy code from example 10-2 into the simple.php file as directed, browser will
display a blank page. PHP script in example is missing else statement and echoes.
The following should be placed in body tags:

<?php
$search = $_GET["search"];
$self=$_SERVER['PHP_SELF'];
if ($search != NULL )
{
echo ("The search string is: $search");
}
else
{
echo
('
<form action="'.$_SERVER["PHP_SELF"].'" method="GET">
<label>Search: <input type="text" name="search" />
</label>
<input type="submit" value="Go!" />
');
}
?>

Anonymous   
Printed Page 197
Line 1 of code in Example 10-10

The opening angle bracket missing--"?php" should be "<?php".

Anonymous   
Printed Page 201
Example 10-11

The description of the example should be:
"The smarty.php file to create" instead of "The index.php file to create". If you
look at the next php example, it calls for smarty.php, but there is no smarty.php.

Anonymous   
Printed Page 214
1st paragraph

The last sentence of the paragraph seems to suggest that ucfirst() turns the first letter of each word into an uppercase one. However, it changes only the first letter of the string.

Anonymous   
Printed Page 214
2nd paragraph

The text claims that stristr() is case sensitive, and strstr() is not. However, strstr() is the case sensitive and stristr() the case insensitive method.

In addition, it might be a good idea to mention what strstr() and stristr() return.

Anonymous   
Printed Page 214
2nd paragraph

"Lastly, there is strops" must be "Lastly, there is strpos".

Anonymous   
Printed Page 216
Example 11-16

The time format from the example "G.i:s" would produce the result "16.18:01", not "4:18:01pm" as indicated. To get that you would need to use "<b>g:</b>i:s<b>a</b>".

Also the Display Format table on 217, at least two of the formats are incorrect

"m" is "Numeric representation of a month, with leading zeros", not "Month of the year abbreviated to three characters"
"M" is three letter month abbreviation, not the full spelled out month.

There may be other errors, I didn't check the whole table. The correct information can be found here: http://pl2.php.net/manual/en/function.date.php

Anonymous   
Printed Page 217
Table 11-2

A wrong meaning is given for the following characters:

m, M

The following characters must be lower case:

R, N

It should be mentioned that the day of year (as given by z) starts from 0.

Anonymous   
Printed Page 226
Table 11-4 and below

$HTTP_POST_FILES should only be used in PHP versions before 4.1.0. In later versions $_FILES should be employed instead.

Anonymous   
Printed Page 234
Example 12-1

The line

echo ("Table created successfully!");

should be included after (rather than before) the database query and error handling (cf. Example 12-2).

Anonymous   
Printed Page 243
1st paragraph

"you can use the add_slashes function"

must be

"you can use the addslashes function".

Anonymous   
Printed Page 249
bottom

Figure 12-13 purports to display output from the mysql command-line
client but is actually a copy of figure 12-14, which is the output
from example 12-12.

Anonymous   
Printed Page 253
Figure 13-1

'echo ($_COOKIE ("test");"

must be

'echo ($_COOKIE ["test"]);'

Anonymous   
Printed Page 254
Table 13-1

"0 for secure and 1 for insecure"

must be

"1 for secure and 0 for insecure".

Anonymous   
Printed Page 261
Figure 13-7

"SessionStart()" should be "session_start()".

"$_session['test']" should be "$_SESSION['test']".

Anonymous   
Printed Page 263
Example 13-14.

6th line in example says...

"DELETE THIS PAR..."

Looks like something that should have been removed by the book's editor.

Anonymous   
Printed Page 267
sentence following Example 13-16

"...sessions.gc_maxlifetime is in 100ths of a second, so, if you want a session timeout of 30 minutes, you would use a value of 18000"

I beleive gc_maxlifetime is given in seconds, not 100ths of seconds. But even if it is in 100ths of a second, the example is incorrect.

18000 * .01 = 180 seconds = 3 minutes (not 30).

Anonymous   
Printed Page 339
Solution to Question 4-12

The given solution describes the meaning of the break keyword within a switch statement, but not its meaning within a loop.

Anonymous   
Printed Page 345
Answer to Question 11-1

The variable to which sprintf() sends the output is not specified as one of its parameters. Rather, sprintf() returns a string.

Anonymous