![]() |
(beginner) syntax error, unexpected '[' - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: (beginner) syntax error, unexpected '[' (/showthread.php?tid=23938) |
(beginner) syntax error, unexpected '[' - El Forum - 10-26-2009 [eluser]rijobo[/eluser] I've got an upload function, which uploads a file and puts the info in the database. When I run this function, I get this error: Parse error: syntax error, unexpected '[' in /usr/home/deb20206/domains/bijvoorbeeldzo.nl/public_html/simo-edelsmid/system/application/controllers/administrator.php on line 36 I expect, that is has got something to do with the $upload_data to the database. Can someone tell me, what I'm doing wrong? This is my function: function upload() { $config['upload_path'] = './uploads/'; $config['allowed_types'] = 'png|gif|jpg'; $config['max_size'] = '10000'; $upload_veld = 'foto'; $this->load->library('upload', $config); if($this->upload->do_upload($upload_veld)) { $upload_data = $this->upload->data(); } else { $data['error'] = $this->upload->display_errors(); } $product = array('naam'=>$_POST['naam'], 'omschrijving'=>$_POST['omschrijving'], 'foto'=>$upload_data['file_name'], 'soort'=>$_POST['soort'], 'steen'=>$_POST['steen'], 'prijs'=>$_POST['prijs'], 'afmeting'=>$_POST['afmeting'], 'materiaal'=>['materiaal']); $this->Productupload->insertRow('product', $product); } (beginner) syntax error, unexpected '[' - El Forum - 10-26-2009 [eluser]jedd[/eluser] [quote author="rijobo" date="1256606782"] ... /usr/home/deb20206/domains/bijvoorbeeldzo.nl/public_html/simo-edelsmid/system/application/controllers/administrator.php [/quote] {falls off chair} Quote:on line 36 You should identify line 36 of your file - presumably you've shown us administrator.php here ? Quote:$product = array('naam'=>$_POST['naam'], 'omschrijving'=>$_POST['omschrijving'], 'foto'=>$upload_data['file_name'], 'soort'=>$_POST['soort'], 'steen'=>$_POST['steen'], 'prijs'=>$_POST['prijs'], 'afmeting'=>$_POST['afmeting'], 'materiaal'=>['materiaal']); The bold bit seems to be missing a $_POST reference. Are you using an IDE, or at least an editor with syntax highlighting? They'll make these kinds of errors pop out at you in a flash. You should look at using the Input class rather than dragging $_POST into play directly. |