janim Posted December 22, 2007 Share Posted December 22, 2007 hi all i have to make script that pulls from mysql and showing the level of this admin like this : <?php function ($admin) { $sql = mysql_query("select * from people where name ='$admin' ") or die("".mysql_error()); if ( mysql_num_rows($sql) ) { fetch = mysql_fetch_array($sql) } if ($fetch['level] == 1 ) { // here the problem }elseif($fetch[level == 2 ){ // here too }elseif($fetch[level] == 3 ) { // here } } so what can i defined in the comments area above to call this function later and authorized admins ? if you noticed that i have a lot of levels ! thanks for any suggestions Quote Link to comment https://forums.phpfreaks.com/topic/82763-admin-levels/ Share on other sites More sharing options...
rarebit Posted December 22, 2007 Share Posted December 22, 2007 The elements of your array's are wrong! Look at what you are doing, some encasement is needed! Quote Link to comment https://forums.phpfreaks.com/topic/82763-admin-levels/#findComment-420926 Share on other sites More sharing options...
trq Posted December 22, 2007 Share Posted December 22, 2007 Sorry, what is your question? All that code is broken as well, you might want to post your actual code. Quote Link to comment https://forums.phpfreaks.com/topic/82763-admin-levels/#findComment-420927 Share on other sites More sharing options...
SirChick Posted December 22, 2007 Share Posted December 22, 2007 <?php if ($fetch['level] == 1 ) { // here the problem }elseif($fetch[level == 2 ){ // here too }elseif($fetch[level] == 3 ) { // here } } notice this difference: <?php if ($fetch['level'] == 1 ) { // here the problem }elseif($fetch['level'] == 2 ){ // here too }elseif($fetch['level'] == 3 ) { // here } } the colour of the script gives away something is not closed in your attempt it should be ['level'] Quote Link to comment https://forums.phpfreaks.com/topic/82763-admin-levels/#findComment-420929 Share on other sites More sharing options...
janim Posted December 22, 2007 Author Share Posted December 22, 2007 ah , i'm so sorry about this code i just typed it know but the idea is : it dosent matter know from where to get these levels but i want to something like defining value like this : <?php function auth($someone) { global $ptab; $admin_sql = mysql_query("select * from $ptab where name = '$someone' "); if (mysql_num_rows($admin_sql)) { $fetch = mysql_fetch_array($admin_sql); } if ( $fetch['lvl'] == 1 ) { // do something }elseif($fetch['lvl'] == 2 ) { // do something }elseif($fetch['lvl'] == 3 ) { // do something } } // end function auth ; ?> // so i dont know how to call this function !!!!!!!!! // but this is the idea i want the authorization in this way // thanks for your replay Quote Link to comment https://forums.phpfreaks.com/topic/82763-admin-levels/#findComment-420932 Share on other sites More sharing options...
revraz Posted December 22, 2007 Share Posted December 22, 2007 You don't know how to call the function? You use the name you defined it with along with it's parameter auth ("joe") Quote Link to comment https://forums.phpfreaks.com/topic/82763-admin-levels/#findComment-420934 Share on other sites More sharing options...
rarebit Posted December 22, 2007 Share Posted December 22, 2007 you'd think with a signature which defines a function, then calls it would understand that piece of code! Quote Link to comment https://forums.phpfreaks.com/topic/82763-admin-levels/#findComment-420935 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.