saamde Posted October 21, 2013 Share Posted October 21, 2013 (edited) Hello, i'v been following a tut on how to make a register and login system and iv hit a brick wall... It won't display data.. This is my users.php <?php function user_data($user_id) { $data = array(); $user_id = (int)$user_id; $func_num_args = func_num_args(); $func_get_args = func_get_args(); if ($func_num_args > 1) { unset($func_get_args[0]); $fields = '`' . implode('`, `', $func_get_args) . '`'; $data = mysql_fetch_assoc(mysql_query("SELECT $fields FROM `users` WHERE `user_id` = $user_id")); return $data; } } function logged_in() { return (isset($_SESSION['user_id'])) ? true : false; } function user_exists($username) { $username = sanitize ($username); (mysql_result(mysql_query("SELECT COUNT(`user_id`) FROM `users` WHERE `username` = '$username'"), 0) == 1) ? true : false; } function user_active($username) { $username = sanitize ($username); return (mysql_result(mysql_query("SELECT COUNT(`user_id`) FROM `users` WHERE `username` = '$username' AND `active` = 1"), 0) == 1) ? true : false; } function user_id_from_username($username) { $username = sanitize($username); return mysql_result(mysql_query("SELECT `user_id` FROM `users` WHERE `username` = '$username'"), 0, 'user_id'); } function login($username, $password) { $user_id = user_id_from_username($username); $username = sanitize($username); $password = md5($password); return (mysql_result(mysql_query("SELECT COUNT(`user_id`) FROM `users` WHERE `username` = '$username' AND `password` = '$password'"), 0) ==1) ? '$user_id' : false; } ?> and iv used this(see code) to get the user first name, Hello, <?php echo $user_data['first_name']; ?>! buts its showing like this...(see image) Help anyone? Thanks, Sam If you need to see some other code files, let me know and ill post. Edited October 21, 2013 by saamde Quote Link to comment Share on other sites More sharing options...
requinix Posted October 21, 2013 Share Posted October 21, 2013 And what's the code that sets $user_data? Also, user_data() won't return anything if you don't pass it the fields you want returned. If a function returns a value then it should always return a value. Maybe you can assume a default of getting all the fields? Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted October 21, 2013 Share Posted October 21, 2013 (edited) Hello, i'v been following a tut on how to make a register and login system What is this tutorial? I am sensing daja vu http://forums.phpfreaks.com/topic/282635-cannot-view-the-fields-unless-i-state-select-all-but-it-still-does-not-work/ Is this a repost? Edited October 21, 2013 by Ch0cu3r Quote Link to comment Share on other sites More sharing options...
requinix Posted October 21, 2013 Share Posted October 21, 2013 Is this a repost?Probably. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.