خرید بک لینک

Vote count: 0

I have a user_data() function on my website which is supposed to grab a users data from the database when they are logged in.

I don't see a problem with the code I have entered, however, it is still retuing the following error:

syntax error, unexpected '$user_data' (T_VARIABLE), expecting ',' or ';' in /filepath

The following is my initialisation script (init.php) in which I set the $user_data variable - to be used on pages such as the profile page:

require_once '_DB/co.php';

// FUNCTIONS

require_once '_func/class.php';

if(logged_in() === true){
    $s_user = $_SESSION['user_id']; // the session is equal to the logged in users useame.
    $user_data = user_data($co, $s_user, 'id', 'fname', 'lname', 'password', 'email', 'reg_date', 'bio', 'profile', 'type', 'active', 'group');
}

This is the class.php script which is situated inside of the _func/ directory (inside of my core folder):

function user_data($co, $s_user){
    $data = array();

    $func_num_args = func_num_args();
    $func_get_args = func_get_args();

    if($func_num_args > 1){
        unset($func_get_args[0]);

        $field = '`' . implode('`, `', $func_get_args) . '`';
        $data = mysqli_fetch_assoc(mysqli_query($co, "SELECT $fields FROM `users` WHERE `useame` = $s_user "));

        retu $data;
    }
}

and this is the index.php script which is inside of my root directory. Here, I try to echo out the first name:

<?php
    include 'core/init.php';

    echo $user_data['fname']; // echo out first name
?>

However, it is still stating that their is a syntax error. When it shouldn't be. I have checked other sites and answers, but to find no fix.

All help is appreciated :)

Also, if you have any other tips on how I could improve this code, it would be more than welcome! thanks :)

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 15 خرداد 1395 ساعت: 13:08

صفحه بندی