CodeIgniter Forums
Error-Object of class could not be converted to string - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Error-Object of class could not be converted to string (/thread-44448.html)



Error-Object of class could not be converted to string - El Forum - 08-15-2011

[eluser]Tanvir[/eluser]
I am new to codeigniter.I have the following files

controller/products/shoes.php And views/products/shoesview.html

This is the controller class shoes.php -

Code:
<?php
class Shoes extends CI_Controller
{
    public function index()
    {
    $$this->load->view('products/shoesview');
    }
}
?>
The view file-shoesview.html is a simple html file.
Now if i try this as url - ..localhost/codeigniter/index.php/products/shoes
I get the following error-
A PHP Error was encountered

Severity: 4096

Message: Object of class Shoes could not be converted to string

Filename: products/shoes.php

Line Number: 17
Fatal error: Call to a member function view() on a non-object in C:\xampp\htdocs\CodeIgniter\application\controllers\products\shoes.php on line 17


Error-Object of class could not be converted to string - El Forum - 08-15-2011

[eluser]Kamarg[/eluser]
Your second error is because you have two '$' on the line you're loading the view. Can't comment on the first problem without seeing the view.


Error-Object of class could not be converted to string - El Forum - 08-15-2011

[eluser]Tanvir[/eluser]
upppss...that was a typing mistake...Yet it is not working..Now it says-

"An Error Was Encountered
Unable to load the requested file: products/shoesview.php"

this is my shoesview.html
Code:
<html>
<head>
<title>Untitled Document</title>
</head>

<body>
<h1> THIS IS A SHOES VIEW </h1>
&lt;/body&gt;
&lt;/html&gt;



Error-Object of class could not be converted to string - El Forum - 08-15-2011

[eluser]Jônatan fróes[/eluser]
Rename the file shoesview.html to shoesview.php


Error-Object of class could not be converted to string - El Forum - 08-15-2011

[eluser]Tanvir[/eluser]
THNX A LOT....its working now.... but cant I use html as view file?


Error-Object of class could not be converted to string - El Forum - 08-15-2011

[eluser]OliverHR[/eluser]
Yes but you must especify the extension.

Code:
$this->load->view('products/shoesview.html');



Error-Object of class could not be converted to string - El Forum - 08-15-2011

[eluser]Tanvir[/eluser]
THANKS EVERYBODY...........