Errata

Head First Mobile Web

Errata for Head First Mobile Web

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
PDF Page 16
First caption below last paragraph

The caption names the three columns as 'visit', 'right' and 'points'. The column 'right' should be 'main'.

"Each column (visit, right, and points) has a 10px margin...."

remdawg  Jan 14, 2013 
Printed Page 16
Last CSS rule on page

I'm looking at p.16 of the printed book and the last css rule on the page:

#main {
margin: 10px 260px 0 250px;
width: 460px;
}

I don't see how the #main column could be 460 pixels wide and still maintain a 10px gutter between it and the next column. If each column has a 10px margin (according to an earlier css rule), then to fill the 960px body width, I count the following:

( #visit column + margin ) + ( #main column + margin ) + ( #points column + margin ) = body width, or:
( 240px + 10px ) + ( 450px + 10px ) + ( 240px + 10px ) = 960px.

That is, the width of #main is not 460px as stated but 450px.

Owing to my not-so-expert knowledge of HTML/CSS I could be missing something, in which case it would be instructive if someone could set me straight.

Mike Tackett  Mar 05, 2013 
PDF Page 16
Bottom left handwritten comment

In describing...

margin: 10px 260px 0 250px;

...the comment...

"Its left margin of 260px and right margin of 250px..."

...should be reversed and instead state:

"Its right margin of 260px and left margin of 250px..."

Ken A Collins  Sep 02, 2013 
Printed Page 47
1st paragraph (and effectively whole page)

the test site "http://www.blaze.io/mobile" generates a 403 access forbidden error. Blaze software is now part of Akamai ... so where now is the mobile tester located?

Graham Neil Hays  Apr 02, 2015 
Printed Page 47
1st paragraph (and effectively whole page)

mobitest would appear to be at "http://mobitest.akamai.com/m/index.cgi" however the front end appears to be in error as none of the dropdowns work!

Graham Hays  Apr 02, 2015 
Printed Page 108
bottom

Actually the book is fine. But the script Detect Mobile Browsers script caused me a problems.

the problem is how they concatenate the third line... using a + sign.

$mobile_location = 'http:// ' + $_SEVER(etc.)

this caused me problems.

the book uses '.'
ex:
$mobile_location = 'http:// ' . $_SEVER(etc.)

mike connor  May 30, 2012 
Printed Page 228
Bottom of page, code box, last <script> tag

A period is missing in the code.

CURRENT CODE:
<script src="http://code.jquery.com/mobile/1.0rc1/jquery.mobile-1.0rc1min.js"></script>

SHOULD BE CHANGED TO:
<script src="http://code.jquery.com/mobile/1.0rc1/jquery.mobile-1.0rc1.min.js"></script>

Brett Hays  Jan 12, 2013 
Printed Page 258
Image - Code

The php code is wrong:

It should use bracelets {} for the for loop rather than : and endfor

<li data-role="list-divider">Build your colors</li>
<?php
for ($i=0; $i < 6; $i++){
?>

<li class="colorset">
<div data-role="fieldcontain" class="color-input">
<label class="select" for="color- <?php print $i ?>" > Color </label>
<select name="colors[]" id="color- <?php print $i ?>" >
<option value="#000000">Black</option>
<option value="#ffffff">White</option>

</select>
</li>

<?php } ?>

Anonymous  Aug 07, 2013 
Printed Page 268

While I can build Tartans, the list of tartans is no longer appearing as it shows that it should be as on p. 268, and did appear just fine with the ch.6 files. Where is the list of tartans (not the built tartans, the original tartan list) being pulled from in the ch.7 files?

Anonymous  Feb 17, 2013 
PDF Page 277
Sidebar 'Who does what?'

The font used in the 'Function name' column is *really* illegible. Yes, I know it's stylish, but can we please use 'code' fonts for code? It's still code and I still have to read it...

Yes this is where I first noticed it... (and where it first bugged me).

It's probably not as obvious 'in print' .. but on an iPad with the page scaled down it's hard(er) to read.

Leo Marihart  Feb 15, 2012 
Printed Page 280
Example Code

In the tartan-template.php it points to the incorrect file:
<div data-role="header" data-position="fixed">
<a href="../tartans.html" data-rel="back" data-direction="reverse" data-icon="back" />Back</a>

it should be:
<div data-role="header" data-position="fixed">
<a href="../tartans.php" data-rel="back" data-direction="reverse" data-icon="back" />Back</a>

Charles Blackwell  Jul 24, 2012 
Printed Page 280
Source code

How can I get rid of the double slashes in the url? When I use the code in the config.php, it adds an extra slash to the path:

File Location (where directory.php is located):
C:\xampp\htdocs\hfmw\chapter7\tartans

PHP code:
define('TARTAN_DOC_ROOT', '/' . ltrim(substr(dirname(__FILE__), strlen($_SERVER['DOCUMENT_ROOT'])), '/'));
define('PUBLIC_TARTAN_DIR', rtrim(TARTAN_DOC_ROOT, '/') . '/tartans/');

directory.php:
echo PUBLIC_TARTAN_DIR . '<br />';

Results:
/\hfmw\chapter7/tartans/

Why is there an extra slash in the path?

Charles Blackwell  Jul 30, 2012 
PDF Page 280
Not in book, in accompanying code

There is a flaw in the Chapter 7 ready bake PHP code that produces screwed up URLs on a Windows PC. Basically, the URLs to the HTML and image files for the tartans I create have both back slashes and forward slashes.

For example, my files are in the path:

C:\xampp\htdocs\Head_First_Mobile_Web\chapter7

...and the PHP produces relative URLs that contain:

/\Head_First_Mobile_Web\chapter7/

I have traced the root cause to the global variables defined in the config.php file which depend on the value of dirname(__FILE__) but do not take into consideration that it might contain back slashes. I fixed it as follows:

// paths relative to DOCROOT
$file_path_with_forward_slashes = str_replace("\\", "/", dirname(__FILE__));
define('TARTAN_DOC_ROOT', '/' . ltrim(substr($file_path_with_forward_slashes, strlen($_SERVER['DOCUMENT_ROOT'])), '/'));
define('PUBLIC_TARTAN_DIR', rtrim(TARTAN_DOC_ROOT, '/') . '/tartans/');
// Absolute filesystem paths
define('TARTAN_XML_DIR', $file_path_with_forward_slashes . '/tartans/data/');
define('TARTAN_IMAGE_DIR', $file_path_with_forward_slashes . '/tartans/images/');
define('TARTAN_HTML_DIR', $file_path_with_forward_slashes . '/tartans/');

Ken A Collins  Oct 06, 2013 
PDF Page 280
Not in book, in accompanying code

The config.php file in Chapter 7 is missing the closing ?> characters at the end of the file. Amazingly, the code still works, but this should be fixed.

Ken A Collins  Oct 07, 2013 
PDF Page 285
Step 3

It would be helpful if Step 3, which describes modifying the web server's .htaccess file for appcache manifests, acknowledged that there are many .htaccess files and had clarified which one we should update if we are following along with XAMPP.

For example, I found 5 .htaccess files on my PC in the following folders:

C:\xampp\phpMyAdmin\libraries\
C:\xampp\phpMyAdmin\setup\frames\
C:\xampp\phpMyAdmin\setup\lib\
C:\xampp\htdocs\forbidden\
C:\xampp\htdocs\xampp\sqlite\

The files are all one or two lines so I am not sure which one to update.

Ken A Collins  Oct 08, 2013 
Printed Page 307
Top of the page

At the top of page 307 is an exercise. The first step of the exercise has the learner load the Google Gears API javascript file with this URL: http://code.google.com/apis/gears/gears_init.js

It appears the Google Gears project is dead and that URL is no longer valid.

Thor Anderson  Nov 06, 2012 
PDF Page 309
Not in book, in accompanying code

Like I had mentioned in my comments on page 280, the failure to consider Windows file paths containing backslashes rears its ugly head again in the events.php file.

The lines...

require_once(dirname(__FILE__) . '/inc/event_list.inc');
require_once(dirname(__FILE__) . '/inc/event_search.inc');

...should be:

$file_path_with_forward_slashes = str_replace("\\", "/", dirname(__FILE__));
require_once($file_path_with_forward_slashes . '/inc/event_list.inc');
require_once($file_path_with_forward_slashes . '/inc/event_search.inc');

Ken A Collins  Oct 26, 2013 
PDF Page 309
Not in book, in accompanying code

There is a syntax error in events.php that causes an "unexpected 'endforeach' (T_ENDFOREACH)" error. The line...

<? foreach($search->getMatchingEvents() as $event): ?>

...should be:

<?php foreach($search->getMatchingEvents() as $event): ?>

Ken A Collins  Oct 26, 2013 
PDF Page 352
Ready Bake JavaScript

The solution code downloaded from the website gets it right, but the book needs to be updated.

var hasPhoto = (isFound && foundValue != 'true');

should be:

var hasPhoto = (isFound && foundValue != 'true') || false;

Ken A Collins  Jan 19, 2014 
PDF Page 353
center

It would be helpful if you could mention that the <preference ... /> line should be placed inside the <widget> </widget> tags, not after them.

The second line...

<feature name="http://api.phonegap.com/1.0/camera" />

...must be removed entirely and the text suggesting its inclusion should be stricken. This line of code will cause the Tartan Hunt app to terminate abruptly after taking a photo.

The config.xml file stored inside the solution APK file available on the hf-mw.com site does not contain this <feature ... /> line, most likely for the reason I have cited.

Ken A Collins  Jan 19, 2014