[nycphp-talk] print parsing confusion
Dan Cech
dcech at phpwerx.net
Thu Apr 13 14:03:06 EDT 2006
Linux Rocks wrote:
>
> --- Tim Sailer <sailer at bnl.gov> wrote:
>
>> On Thu, Apr 13, 2006 at 08:58:36AM -0700, Linux
>> Rocks wrote:
>>> Hello all:
>>>
>>> I am having a problem trying to get a text field
>> get
>>> its name in a while loop like this expense_cat1,
>>> expense_cat2 ... etc. here's a snip of the code:
>>>
>>> while( $row = mysql_fetch_array( $category ) )
>>> {
>>> echo( "<tr><td>" . $row['expenses_cat_desc'] .
>>> "</td><td><input type=text
>> name=expense_cat" .
>>> $row['expenses_cat_number'] . ("</td></tr>");
>>>
>>> }
>>>
>>> I pass this to another page and try to print it
>> using
>>> $_POST['expense_cat1'] and is giving me an empty
>>> string.
>>>
>>> Now, I check phpinfo() and the variable name gets
>>> created as:
>>>
>>> $_POST['expense_cat1</td>']
>> One, possibly two, problem(s).
>>
>> First,
>> $row['expenses_cat_number'] . ("</td></tr>");
>> ^
>> Where is this from? Looks like unmatched parens.
>> Then, the immediate problem, the line should read
>> like:
>
> The parenthesis were not in the code. I added them
> because I had two echo statements I did a cut a paste
> and forgot to remove the parenthesis. Sorry if that
> threw someone off. The problem is solved by ending the
> input tag with >. Thanks a lot to those who replied.
You should probably also check out this PHundamentals article:
http://www.nyphp.org/phundamentals/storingretrieving.php
You'll find some useful information there about properly escaping data.
Dan
More information about the talk
mailing list