Re: undefined variable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux