Re: [PHP] Undefined constant error
> make sure you have register_globals on in php.ini or your next question > will be 'why isn't $compteur set to the value posted?' Better would be to > change the line to the new magic globals, and learn the right way from > scratch: I agree with you as far, as to learn the right way from scratch - but this is no POST-Var here. > echo " if ($_POST['compteur'] == 1) { > echo "checked"; > } > echo ">"; This is another bug in the script. Considering that, it would be correctly: (Note the space between '"' and 'checked') echo ""; or shorter: echo ""; Regards Sascha -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Undefined constant error
> From: "Voisine" <[EMAIL PROTECTED]> > Sent: Sunday, September 29, 2002 7:52 PM > Subject: [PHP] Undefined constant error > I'm learning PHP from a book "PHP for newbie writen in French" and I > have an error on one of the exemple. Undifined constant 'compteur' on > line 15 which is : > if (compteur == 1) { > > What I'm doing wrong? This is the script > > include("config.inc.php"); > $query = "SELECT * FROM Type ORDER BY animalType"; > $result = mysql_query($query) or die ("Exécution de la sélection > impossible"); > > echo "CatalogueQuel type d'animal > cherchez-vous ?\n"; > echo "\n"; > echo ""; > $compteur = 1; > while ($ligne = mysql_fetch_array($result)) { > extract($ligne); > echo ""; > echo ""; > if (compteur == 1) { you're missing the $ in from of compteur. Should be: if ($compteur == 1) { make sure you have register_globals on in php.ini or your next question will be 'why isn't $compteur set to the value posted?' Better would be to change the line to the new magic globals, and learn the right way from scratch: if ($_POST['compteur'] == 1) { For the full explaination see: http://www.php.net/manual/fr/language.variables.predefined.php > echo "checked"; > } Also, I think this code needs to place the 'checked' within the tag so you end up with: echo ""; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Undefined constant error
There seems to be a print-error in this book. It's missing a '$' This line: > if (compteur == 1) { should be: > if ($compteur == 1) { Sascha Am Montag, 30. September 2002 01:52 schrieb Voisine: > Hello, > > I'm learning PHP from a book "PHP for newbie writen in French" and I > have an error on one of the exemple. Undifined constant 'compteur' on > line 15 which is : > if (compteur == 1) { > > What I'm doing wrong? This is the script > > include("config.inc.php"); > $query = "SELECT * FROM Type ORDER BY animalType"; > $result = mysql_query($query) or die ("Exécution de la sélection > impossible"); > > echo "CatalogueQuel type d'animal > cherchez-vous ?\n"; > echo "\n"; > echo ""; > $compteur = 1; > while ($ligne = mysql_fetch_array($result)) { > extract($ligne); > echo ""; > echo ""; > if (compteur == 1) { > echo "checked"; > } > echo " size='+1'>$animalType$typeDescription"; > > $compteur++; > } > echo ""; > echo ""; > ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php