Welcome Guest, Not a member yet? Register   Sign In
Passing variable to view not working...

I really cannot figure this out.. any help is greatly appreciated.

My controller:

class Welcome extends Controller {

    function Welcome()
    function index()
        $data['username'] = "Hello";
        $this->load->view('welcome_message', $data);

My view:
<?php echo $data['username']; ?>

The error:
Quote:A PHP Error was encountered

Severity: Notice

Message: Undefined variable: data

Filename: views/welcome_message.php

Line Number: 60

In your view you have to use <?php echo $username; ?>. The array passed to the view is "extracted"


Theme © iAndrew 2016 - Forum software by © MyBB