retrieving and showing data |
Then that's his error he is trying to assign an object to an array
Here are to function to handle objects and arrays to convert to each other. PHP Code: if ( ! function_exists('array_to_object')) What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
Hello,
Where to type in that function? In which file? I have this error appears in views/pcategories.php A PHP Error was encountered Severity: Notice Message: Array to string conversion Filename: views/pcategories.php Line Number: 54 Backtrace: File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyGiondaCI\application\views\pcategories.php Line: 54 Function: _error_handler File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyGiondaCI\application\controllers\Cpages.php Line: 47 Function: view File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyGiondaCI\index.php Line: 315 Function: require_once views/pcategories.php PHP Code: <div class="widget-box"> line 54: <tr><?php echo $this->Mpages->call_parentctg(); ?>
" If I looks more intelligence please increase my reputation."
I try to insert that new function in the controllers:
PHP Code: Parse error: syntax error, unexpected 'if' (T_IF), expecting function (T_FUNCTION) in C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyGiondaCI\application\controllers\Cpages.php on line 35 controllers/cpages.php PHP Code: public function __construct() views/pcategories.php PHP Code: <div class="widget-box">
" If I looks more intelligence please increase my reputation."
You place the functions in a CI helper say utility_helper
Then load the helper What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
OP please learn how to code and debugging properly, it's basic thing. You only post same errors in diferrent scenarios. Have a nice day buddy.
Keep calm.
You guys are really patient... I would say that davy_yg is some sort of troll or something spamming all the forum but whatever...
Parse error: syntax error, unexpected 'if' (T_IF), expecting function (T_FUNCTION) in C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyGiondaCI\application\controllers\Cpages.php on line 34
A PHP Error was encountered Severity: Parsing Error Message: syntax error, unexpected 'if' (T_IF), expecting function (T_FUNCTION) Filename: controllers/Cpages.php Line Number: 34 Backtrace: I have a new error that appearing that I am a little bit confuse. Line 34 is: if ( ! function_exists('array_to_object')) This is a little bit confusing to me. Why the error appearing?
" If I looks more intelligence please increase my reputation."
(07-16-2016, 07:18 PM)davy_yg Wrote: Parse error: syntax error, unexpected 'if' (T_IF), expecting function (T_FUNCTION) in C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyGiondaCI\application\controllers\Cpages.php on line 34 Because an if statement is not valid in the body of a class. You can only define methods, properties, and constants in a class. An if statement would have to be either inside a method or outside of the class. One option would be to do something like this: PHP Code: protected function array_to_object($data) Note that I've declared the method as protected, because leaving the visibility off of the method declaration is the same as declaring a public method, and public methods in controllers can be routed or accessed via the URL. |
Welcome Guest, Not a member yet? Register Sign In |