Welcome Guest, Not a member yet? Register   Sign In
retrieving and showing data
#13

(This post was last modified: 07-13-2016, 06:40 PM by davy_yg.)

I try to insert that new function in the controllers:

PHP Code:
Parse errorsyntax errorunexpected 'if' (T_IF), expecting function (T_FUNCTIONin C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyGiondaCI\application\controllers\Cpages.php on line 35
A PHP Error was encountered

Severity
Parsing Error

Message
syntax errorunexpected 'if' (T_IF), expecting function (T_FUNCTION)

Filenamecontrollers/Cpages.php

Line Number
35

Backtrace



controllers/cpages.php


PHP Code:
public function __construct()
    {
        
parent::__construct();
        
        
$this->load->helper('url');
        
$this->load->helper('url_helper');
        
$this->load->helper('form');
        
        
$this->load->library('form_validation');
        
        
$this->load->model('Mpages');
    }
     
    if ( ! 
function_exists('array_to_object'))
    {
 
   /**
     * array_to_object ()
     * --------------------------------------------------------------------
     *
     * Converts an array to an object.
     *
     * @param   $data
     * @return  object
     */
 
   function array_to_object($data)
 
   {
 
       if (is_array($data))
 
       {
 
           /**
             * Return array converted to object Using __FUNCTION__
             * (Magic constant) for recursive call
             */
 
           return (object) array_map(__FUNCTION__$data);
 
       }
 
       else
        
{
 
           return $data;
 
       }
 
   }
}

if ( ! 
function_exists('object_to_array'))
{
 
   /**
     * object_to_array ()
     * --------------------------------------------------------------------
     *
     * Converts an object to an array.
     *
     * USAGE: $array = object_to_array($object);
     *
     * @param $obj
     * @return array
     */
 
   function object_to_array($obj)
 
   {
 
       if (is_object($obj))
 
       {
 
           // Gets the properties of the given object with get_object_vars function
 
           $obj get_object_vars($obj);
 
       }

 
       if (is_array($obj))
 
       {
 
           /**
             * Return array converted to object Using __FUNCTION__
             * (Magic constant) for recursive call
             */
 
           return array_map(__FUNCTION__$obj);
 
       }
 
       else
        
{
 
           return $obj;
 
       }
 
   }
    } 
 
    public function 
index() { $this->load->view('index'); }
    
    public function 
categories() { $this->load->view('categories');} 



views/pcategories.php


PHP Code:
<div class="widget-box">
                        <
div class="widget-title"><h5>Parent Categories</h5></div>
                        <
div class="widget-content">
                        
                        <
table border="0" style="width: 100%; height: 90px;">
                            <
tr>
                                <
td>PARENT NAME</td>
                                <
td>DESCRIPTION</td>
                                <
td>EDIT</td>
                                <
td>DELETE</td>    
                            </
td>
                            
                            <?
php// foreach($posts as $post){?>
                            <tr><?php echo $this->Mpages->call_parentctg(); ?>
                                <td><?php echo /*$data['ctgparent_name'];*/ $ctgparent_name?></td>
                                <td><?php echo /*$data['ctgparent_description'];*/ $ctgparent_description?></td>
                                <td><button type="button" class="edit" onclick="location.href='<?php echo site_url('cpages/editparentctg'); ?>';">EDIT</button></td>
                                <td><button type="button" class="delete" href="adminform.php">DELETE</button></td>    
                            </td>    
                            <tr>
                                <td><?php //echo $data['ctgparent_name']; ?></td>
                                <td><?php //echo $data['ctgparent_description']; ?></td>
                                <td><button type="button" class="edit" onclick="location.href='<?php echo site_url('cpages/addparentctg'); ?>';">EDIT</button></td>
                                <td><button type="button" class="delete" href="adminform.php">DELETE</button></td>    
                            </td>
                            <?php// }?> 
                            
                        </table>            
                        </div>
                    </div> 
" If I looks more intelligence please increase my reputation."
Reply


Messages In This Thread
retrieving and showing data - by davy_yg - 07-12-2016, 07:34 AM
RE: retrieving and showing data - by arma7x - 07-12-2016, 07:44 AM
RE: retrieving and showing data - by davy_yg - 07-12-2016, 07:53 AM
RE: retrieving and showing data - by arma7x - 07-12-2016, 08:09 AM
RE: retrieving and showing data - by mwhitney - 07-12-2016, 08:26 AM
RE: retrieving and showing data - by rtenny - 07-12-2016, 09:18 AM
RE: retrieving and showing data - by davy_yg - 07-12-2016, 09:30 PM
RE: retrieving and showing data - by rtenny - 07-13-2016, 09:19 AM
RE: retrieving and showing data - by InsiteFX - 07-12-2016, 07:10 PM
RE: retrieving and showing data - by InsiteFX - 07-13-2016, 07:42 AM
RE: retrieving and showing data - by InsiteFX - 07-13-2016, 10:14 AM
RE: retrieving and showing data - by davy_yg - 07-13-2016, 06:31 PM
RE: retrieving and showing data - by davy_yg - 07-13-2016, 06:36 PM
RE: retrieving and showing data - by InsiteFX - 07-14-2016, 03:08 AM
RE: retrieving and showing data - by arma7x - 07-14-2016, 03:46 AM
RE: retrieving and showing data - by Ivo Miranda - 07-14-2016, 04:13 AM
RE: retrieving and showing data - by davy_yg - 07-16-2016, 07:18 PM
RE: retrieving and showing data - by mwhitney - 07-18-2016, 01:56 PM



Theme © iAndrew 2016 - Forum software by © MyBB