> 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 > > <?php > 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 "<h1 align='center'>Catalogue</h1><p><h3>Quel type d'animal > cherchez-vous ?</h3>\n"; > echo "<form action='montre_animaux.php' method='post'>\n"; > echo "<table cellpadding='5' border='1'>"; > $compteur = 1; > while ($ligne = mysql_fetch_array($result)) { > extract($ligne); > echo "<tr><td valign='top' width='15%'>"; > echo "<input type='radio' name='interet' value='$animalType'>"; > 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 <input type="radio"> tag so you end up with: echo "<input type='radio' name='interet' value='$animalType'"; if ($_POST['compteur'] == 1) { echo "checked"; } echo ">"; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php