Welcome Guest, Not a member yet? Register   Sign In
'Array" showing up all over my app
#1

[eluser]Chad Crowell[/eluser]
http://rj.webinception.com/index.php/sell

Notice at the top of the form the word Array? Also it shows up im my header in several places.

Anyone know why??

Here is the code that starts the form:
Code:
<?=$attributes = array('class' => 'form', 'id' => 'sellform');
echo form_open('sell/images', $attributes);?>

And the search area of the header:
Code:
<?=$attributes = array('class' => 'form', 'id' => 'searchform');
                echo form_open('search', $attributes);?>
                Search
                <?=$data = array(
                  'name'        => 'txtsearch',
                  'id'          => 'txtsearch',
                  'value'       => '',
                  'maxlength'   => '',
                  'size'        => '',
                  'style'       => '',
                );                
                echo form_input($data);?>

                <?=$options = array(
                    ''      => 'In All Categories',
                    #foreach($categories as $category):
                    #    $category->shortname    => $category->category_name,;
                    #endforeach;
                );
                echo form_dropdown('searchcat', $options);?>

                <?echo form_close();?>

Why does CI keep printing out the word 'Array'?
#2

[eluser]PsyCow[/eluser]
PHP short tags return your $data array.

Try this :
Code:
<?php $attributes = array('class' => 'form', 'id' => 'sellform');
echo form_open('sell/images', $attributes); ?>
And again for your next snippet.

PHP short tags "<?=$var?>" is equal to "<?php echo $var; ?>".
So when you use it to set your variables $attributes, $data, and $options, it will return the array and so print 'Array' on your page.
#3

[eluser]coolfactor[/eluser]
Code:
'style' => '',
...
''      => 'In All Categories',

The last element in an array should not be followed by a comma.
#4

[eluser]Bulk[/eluser]
[quote author="coolfactor" date="1184243549"]
Code:
'style' => '',
...
''      => 'In All Categories',

The last element in an array should not be followed by a comma.[/quote]

IMO Only for style reasons - PHP has never thrown an error for that reason for me...
#5

[eluser]coolfactor[/eluser]
Okay, my servers don't like it. Must be a different error threshold.
#6

[eluser]Bulk[/eluser]
Really? :o what error level are you set at? In my dev enviroment I though it was showing everything...
#7

[eluser]coolfactor[/eluser]
Actually, I think you're right. I'm not getting any errors. I must've been thinking about Javascript, which doesn't like that.
#8

[eluser]Bulk[/eluser]
Ah yeah thats true, IE goes nuts if you do that Sad
#9

[eluser]Chad Crowell[/eluser]
CF I generally do it that way, but I noticed in the CI user guide that they do include trailing commas, so I don't go out of my way to avoid them.




Theme © iAndrew 2016 - Forum software by © MyBB