Welcome Guest, Not a member yet? Register   Sign In
Noob: Trouble using Models, Parse Errors & The like occur :(
#1

(This post was last modified: 04-02-2015, 11:24 AM by ciadmin.)

[eluser]Unknown[/eluser]
I must start off by saying I\'m usually the type to just get really stubborn and figure it out on my own but this time I must admit I really need some help Tongue

Okay so lets get into it. I decided to use CI to code my website because I wanted to create a lean, very simple content managing system. Right now I\'m trying to pull text out of a database and display it on a page. I keep getting PHP Parse errors however, having messed around with it and getting different error messages Tongue
Here\'s what I have now:
Parse error: syntax error, unexpected T_STATIC, expecting T_STRING in [...]/system/application/models/static.php on line 2

Here\'s the code for my Model (it exists in the models folder as static.php):
Code:
<?php
class Static extends Model {

var $content    = \'\';

   function Static()
   {
       parent::Model();
   }
    function show_about_block()
   {
   $sql = \"SELECT content FROM static LIMIT 1\";
    
$this->db->query($sql);
   return $this;
   }
    }
    ?>

I\'m guessing you\'ll need the
controller and the View too so here goes:
Controller (exists in controllers folder as
home.php):
Code:
<?php

class Home extends Controller {

   function Home()
   {
    
parent::Controller();    
   }
   
   function index()
   {
    
$this->load->model(\'static\');
               $data[\'about\'] =
$this->static->show_about_block();
       $this->load->view(\'home_page\', $data);
        
}
}
?>
And Finally View (exists in views folder as
home_page.php):
Code:
<html>
<head>
<title>DeadRinger</title>
<!--
(REMOVED CSS TO SAVE SPACE IN THIS POST) ->
</head>
<body>

<h1>DeadRinger Media -
COMING SOON</h1>

<p>Test:</p>

<p>&lt;?php echo $about
?&gt;</p>

&lt;/body&gt;
&lt;/html&gt;

Let me know if you\'ll want information about my
Database too! Thanks so much in advance! I\'ll see if perhaps I can return the favor somehow.

Thanks
again,
Sean"
#2

[eluser]woopsicle[/eluser]
static is a reserved word in PHP
try changing your model name to something else.

edit: FYI - http://au2.php.net/manual/en/reserved.php
#3

[eluser]Unknown[/eluser]
Ahh! Big thanks. It\'s always the simple stuff isn\'t it?

Edit: Still having some errors but nothing I can\'t work out so my code isn\'t as it was when I posted anymore, I\'ve wrinkled out a lot of kinks.




Theme © iAndrew 2016 - Forum software by © MyBB