Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5
This is the forum to discuss the Wrox book Beginning PHP4 by Wankyu Choi, Allan Kent, Chris Lea, Ganesh Prasad, Chris Ullman; ISBN: 9780764543647
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 3rd, 2003, 05:00 AM
Authorized User
 
Join Date: Sep 2003
Location: , , .
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default hangman.php.....

in the chapter 8 of the php4 book, there is a example named hangamn.php that explains the usage of query string for permanent data. In my opinion, there is an error in this example, because the variable $letters is not defined. I tried to do this example changing to italian language the name and value of variables (i'm italan..eheh:-)), but the result is the same: when I load hangamn.php and select a letter, the page failure to reload.
Is the example tht is wrong or is my code wrong? Can you help me?

This is my code:

<html>
<head>
<title>Documento senza titolo</title>
</head>

<body>
<?php

//impiccato.php

$alfabeto = array ("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z");

$parole = array ("GIOVANNI", "SBARBARE", "CANZONE", "PENZOLARE", "SPLINTERCELL");

$errori = 0;

if (!isset($numeroParola)) {
    $numeroParola = rand(1, count($parole)) -1;
    }
echo "<H1>";
$parolaSingola = $parole[$numeroParola];
$fine = 1;
for ($counter = 0; $counter < strlen($parolaSingola); $counter++) {
    if (ereg($parolaSingola[$counter], $lettere)) {
        echo $parolaSingola[$counter];
        } else {
        echo "_";
        $fine = 0;
        }
}
echo "</H1>";
if ($fine) {
    echo "<br><br> congratulzioni..hai vinto <br><br>";
    echo "<br><br> <A HREF = $PHP_SELF>gioca ancora</A>";
} else {
    foreach ($alfabeto as $indice) {
        if (ereg($indice, $lettere)) {
            if (ereg($indice, $parole[$numeroParola])) {
            $collegamento .= "<b> $indice </b>";
            } else {
            $collegamento .= "$indice";
            $errori++;
            }
        } else {
        $collegamento .= "<A HREF=\"$PHP_SELF?lettere=$lettere$indice&numeroPar ola=$numeroParola\">$indice</A>";
        }
    } if ($errori == 12) {
        echo "<br>IMPICCATO!!<br><br>";
        echo "la parola da indovinare era \"$parolaSingola\"<br><br>";
        echo "<A HREF = $PHP_SELF>rigioca</A>";
     } else {
         echo "tentativi rimanenti " . (12 - $errori) . "<br>";
        echo "<br>seleziona una lettera. <br><br>";
        echo $collegamento;
        }
}

?>

</body>
</html>
 
Old October 3rd, 2003, 04:53 PM
Friend of Wrox
Points: 2,570, Level: 21
Points: 2,570, Level: 21 Points: 2,570, Level: 21 Points: 2,570, Level: 21
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: San Diego, CA, USA
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Cross post with http://p2p.wrox.com/topic.asp?TOPIC_ID=4833

Please post all replies to that thread.


Take care,

Nik
http://www.bigaction.org/




Similar Threads
Thread Thread Starter Forum Replies Last Post
Letter replace in hangman. martoufmarty Javascript How-To 12 June 17th, 2008 12:30 AM
Error: movie.php & commit.php on p182-186, ch6 willburke BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 0 October 12th, 2004 02:48 PM
hangman games becu BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 1 September 19th, 2004 06:42 PM
hangman.php in chapter 8... joeore BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 1 October 3rd, 2003 04:52 PM
Hangman Help Popfaen BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 0 July 1st, 2003 05:10 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.