Welcome Guest, Not a member yet? Register   Sign In
Error-Object of class could not be converted to string
#1

[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
#2

[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.
#3

[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;
#4

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

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

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

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

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




Theme © iAndrew 2016 - Forum software by © MyBB