text book syntax error and what do you replace a command with for older PHP?

I’m a Beginner learning from a horrible book called PHP programming with MySql and I’m stuck with 2 problems.

  1. I keep getting a syntax error even though it’s typed in exactly as the book calls for.
  2. It calls for the strlength function which according to PHP.net isn’t going to work right with what we are using (5.2 for the web host and on my mac)

Anyone see what’s wrong with 1 and does anyone know a workaround for problem 2?

To top it off…our instructor just took another job, so I pretty much am stuck with just this lame book to go by… :o

Here’s the code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" <?php $Books = array("The Adventures of Huckleberry Finn", "Nineteen Eighty-Four", "Alice's Adventures in Wonderland", "The Cat in the Hat"); for ($i = 0; $i < count($Books); ++$i) echo "

The title \ " {$Books[,$i]} \ " contains " . strlen($Books[$i]) . " characters and " . str_word_count($Books[$i]) . " words.

";

?>

Hi there,

Try removing the “,” from “{$Books[,$i]}” at the beggining of the echo in your for loop.

Sponsor our Newsletter | Privacy Policy | Terms of Service