Re: undefined variable

From: Date: Sat, 29 Apr 2006 21:43:13 +0000
Subject: Re: undefined variable
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-235116@lists.php.net to get a copy of this message
On Sat, April 29, 2006 5:42 am, Smart Software wrote: > code below shows all records from products table with an textbox and > an > order button for each record > How can i add the content of the textbox? > i tried this: > <td width="40%"> <a href="<? echo > "products.php?cat=$cat&quantity=$quantity&toevoegen=1&id=$rowType[7]"; > ?>"><img src="images/bestel1.gif" > border="0"></a></td> > > but all i get is an error telling me there is a undefined varable You probably are following some kind of tutorial that assumes "register_globals" is "on" -- or you are simply used to that environment. So when you try to use $quantity, it's not defined. The value you want is in $_REQUEST['quantity']; You should do something like this: <?php //Get data from REQUEST: $quantity = isset($_REQUEST['quantity']) ? $_REQUEST['quantity'] : 0; //Force valid data: $quantity = (int) $quantity; //rest of script here. ?> -- Like Music? http://l-i-e.com/artists.htm

« previous php.general (#235116) next »