Syntax error calling a class method

Syntax error calling a class method

Page 1 of 1

4 Replies - 1107 Views - Last Post: 25 November 2012 - 11:05 AM Rate Topic: -----

#1 sangeetha_s  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 94
  • Joined: 15-November 12

Syntax error calling a class method

Posted 17 November 2012 - 11:40 AM

i am getting some error in this on line 6 some syntax error
<?php  
        class Helloworld extends Controller{  
            function index()  
            {  
                $this->load->model('helloworld_model');  
                $data['result'] = $this->helloworld_model-> <span class="sql">getData</span>();  
                $data['page_title'] = "CI Hello World App!";  
                $this->load->view('helloworld_view',$data);  
            }  
        }  
    ?>  



Is This A Good Question/Topic? 0
  • +

Replies To: Syntax error calling a class method

#2 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3077
  • View blog
  • Posts: 10,790
  • Joined: 08-August 08

Re: Syntax error calling a class method

Posted 17 November 2012 - 01:49 PM

When you've got a new question and new code please use a new topic.
Look at the line:
                $data['result'] = $this->helloworld_model-> <span class="sql">getData</span>();  

Are PHP and HTML the same language? Are they even processed on the same machine?
Was This Post Helpful? 1
  • +
  • -

#3 sangeetha_s  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 94
  • Joined: 15-November 12

Re: Syntax error calling a class method

Posted 25 November 2012 - 09:14 AM

still this error is not solved this error is coming continuously please help me to solve this error

Parse error: syntax error, unexpected '<', expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in C:\xampp\htdocs\CI\application\controllers\helloworld.php on line 6

<?php  
        class Helloworld extends Controller{  
            function index()  
            {  
                $this->load->model('helloworld_model');  
                $data['result'] = $this->helloworld_model-><span class="sql">getData</span>();  
                $data['page_title'] = "CI Hello World App!";  
                $this->load->view('helloworld_view',$data);  
            }  
        }  
    ?>  




This is the code
Was This Post Helpful? 0
  • +
  • -

#4 Xupicor  Icon User is offline

  • Nasal Demon
  • member icon

Reputation: 249
  • View blog
  • Posts: 582
  • Joined: 31-May 11

Re: Syntax error calling a class method

Posted 25 November 2012 - 10:55 AM

You're saying "still" even though you haven't changed the code with accordance to what CTphpnwb wrote?

Look closer - you have HTML mixed with your PHP. It gets parsed as PHP, because it's between <?php and ?> and it is not a string, HEREDOC/NOWDOC block, nor in a comment.
Code illustration:
<?php
$hello = "world";
<div class="$hello"></div>

This doesn't make sense, because the HTML is treated like PHP code. Same in your code in line 06. If you don't get why, go back to basic PHP tutorials/books.
Was This Post Helpful? 0
  • +
  • -

#5 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6092
  • View blog
  • Posts: 23,612
  • Joined: 23-August 08

Re: Syntax error calling a class method

Posted 25 November 2012 - 11:05 AM

Copying and pasting code with no understanding does NOT make you a programmer.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1