Welcome Guest, Not a member yet? Register   Sign In
undefined variables
#1

[eluser]cityzen[/eluser]
So I am somewhat new to CI and OOP, know PHP pretty well. I keep getting these "Undefined variable" notices. I am using a form to both and or update data which looks like:

Code:
<p><label for="title">Title:</label>&lt;input type="text" name="title" value="&lt;?= $title ?&gt;"/&gt;</p>
<p><label for="link">Link:</label>&lt;input type="text" name="link" value="&lt;?= $link ?&gt;" /&gt;</p>

and my controller looks like:

Code:
function add(){
        $data['title'] = '';
        $this->load->view('news/addmod', $data);            
    }

Do i really have to keep declaring or defining the variable in each function? It seems a bit round about to me. I'm really trying to understand and adhere to best coding practices so if anyone can let me know what the normal practice is for declaring variables like that, I would appreciate it. My background is in somewhat hacked PHP so I've never been really clean about declaring or defining all of my variables (since error/notice reporting is pretty lax). Also, is there a way to turn off that level of error reporting and only show actual warnings?

Thanks!

Mike


Messages In This Thread
undefined variables - by El Forum - 05-21-2008, 02:00 AM
undefined variables - by El Forum - 05-21-2008, 02:16 AM
undefined variables - by El Forum - 05-21-2008, 02:44 AM



Theme © iAndrew 2016 - Forum software by © MyBB