almightyegg Posted October 25, 2006 Author Share Posted October 25, 2006 and am i still using [code=php:0]$GET = $mem[id];[/code] ?? Quote Link to comment https://forums.phpfreaks.com/topic/24975-showing-other-members-profile/page/2/#findComment-114131 Share on other sites More sharing options...
HuggieBear Posted October 25, 2006 Share Posted October 25, 2006 Don't call your variable $GET as it's too much like $_GET which is a predefined variable in php.I'll post a simple bit of code for you to just see if it works, then complicate it and fit the other bits around it. I've taken this nearly all from your code so it looks familiar to you.[code]<?php// Connect to the databaseinclude 'database.php';// Query the database and assign the results to a variable$view = "SELECT * FROM users WHERE id = '{$_GET['id']}' LIMIT 1";$view2 = mysql_query($view) or die("Couldn't execute $sql:\n\n" . mysql_error());$view3 = mysql_fetch_assoc($view2) or die("Couldn't fetch the results:" . mysql_error());$user = $view3['username'];$admin_ids = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);foreach ($admin_ids as $id){ if ($view3['id'] == $id){ $admin = "y"; }}if ($admin == "y"){ echo "{$view3['username']} is an administrator\n";}else { echo "{$view3['username']} is not an administrator\n";}?>[/code]Call this code something like testforadmin.php and make sure you pass it a value like this testforadmin.php?id=3Post any errors that you get here.RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/24975-showing-other-members-profile/page/2/#findComment-114137 Share on other sites More sharing options...
almightyegg Posted October 25, 2006 Author Share Posted October 25, 2006 thanks it worked perfectly, have started to tweak it now with other column values etc... thanks again ;D Quote Link to comment https://forums.phpfreaks.com/topic/24975-showing-other-members-profile/page/2/#findComment-114140 Share on other sites More sharing options...
HuggieBear Posted October 25, 2006 Share Posted October 25, 2006 OK, well I'm glad that it worked. You could reduce the overhead even more by including a 'role' column in your database that designates whether the user is 'admin' or not...This way you can do away with the $admin_ids array and use the value from the database to check if their admin or not. Something like this...[code]<?phpif ($view3['role'] == "admin"){ echo "{$view3['username']} is an administrator\n";}else { echo "{$view3['username']} is not an administrator\n";}?>[/code]RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/24975-showing-other-members-profile/page/2/#findComment-114144 Share on other sites More sharing options...
almightyegg Posted October 25, 2006 Author Share Posted October 25, 2006 yes i may do that, i have that column already, but i had it when i couldn't even do [code=php:0]echo "Hello World!";[/code] :D Quote Link to comment https://forums.phpfreaks.com/topic/24975-showing-other-members-profile/page/2/#findComment-114145 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.