Welcome Guest, Not a member yet? Register   Sign In
parse error, expecting `T_STRING' or `T_VARIABLE'
#1

[eluser]thoque[/eluser]
Hi I am new to php programming and obviously new to Codeigniter. I was following a tutorial but my code is not working.
The output is as following:
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `'{'' or `'$'' in C:\wamp\www\CodeIgniter_1.7.1\system\application\controllers\helloworld.php on line 7

Code:
//helloworld_view.php
<html>  
    <head>  
        <title><?=$page_title?></title>  
    </head>  
    <body>  
        <?php foreach($result as $row):?>  
        <h3>&lt;?=$row->title?&gt;</h3>  
        <p>&lt;?=$row->text?&gt;</p>  
        <br />  
        &lt;?php endforeach;?&gt;  
    &lt;/body&gt;  
&lt;/html&gt;

//helloworld.php
&lt;?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);  
        }  
    }  
?&gt;  

//helloworld_model.php
&lt;?php  
class Helloworld_model extends Model {  
  
    function Helloworld_model()  
    {  
        // Call the Model constructor  
        parent::Model();  
    }  
      
    function getData()  
        {  
            //Query the data table for every record and row  
            $query = $this->db->get('data');  
              
            if ($query->num_rows() < 0)  
            {  
                //show_error('Database is empty!');  
            }else{  
                return $query->result();  
            }  
        }  
  
}  
?&gt;

Could any body tell me what is wrong here.
#2

[eluser]wiredesignz[/eluser]
You have HTML mixed into the PHP code on line 7 of your "Helloworld" controller.
#3

[eluser]eoinmcg[/eluser]
As the error message and wiredesignz says it's all in line 7

change:
Code:
$data['result'] = $this->helloworld_model-><span class="sql">getData</span>()

to:
Code:
$data['result'] = $this->helloworld_model->getData();




Theme © iAndrew 2016 - Forum software by © MyBB