Jump to content
MakeWebGames

Recommended Posts

Posted

Now ive been trying staff colours, and ive been using this code in globals.php

  function username($user_level,$username) {
       $staff_colours = array(
   0 => '#000', 
   1 => '#fff', 
   2 => '#CC0', 
   3 => '#FFC', 
   5 => '#006'
       );
       $return_data = (array_key_exists($user_level, $staff_colours)) ? '<span style="color: '.$staff_colours[$user_level].';">'.$username.'</span>' : $username ;
   return $return_data;
 }
  echo username($ir['user_level'],$ir['username']);

 

Ive put it in the right place in that file, but it still wont change the colour of staffs names on the site :/ So whats wrong with that code?

Posted

well take it out of globals.php and use a file like this and see if it errors to test the function

 

 

<?php 
include "globals.php"; 
function username($user_level,$username) { 
$staff_colours = array( 
0 => '#000', 
1 => '#fff', 
2 => '#CC0', 
3 => '#FFC', 
5 => '#006' 
); 
$return_data = (array_key_exists($user_level, $staff_colours)) ? '<span style="color: '.$staff_colours[$user_level].';">'.$username.'</span>' : $username ; 
return $return_data; 
} 
echo username($ir['user_level'],$ir['username']); 
?> 

 

if it errors post the error if it shows your name as whatever colour you have set it to then your using the function wrong ><

Posted

Functions are not automatic. You are specifying a set of instructions which will be processed every time you call the function name.

So through your game if you wish to use that function then where you have

$ir['username']

change it to

username($ir['user_level'],$ir['username'])

Posted

That would be as Paul has and is still learning PHP rather than copying with no idea what it is your copying.

No offence but at least attempt to learn and understand what it is your copying!

I use something like it on zu. More advanced too :D

Posted

mine works out the colours linking (which uses my link function) and optional adds image (don't ask) also implicating some other upgrades at a later date, when MakeWebGames coded that it was just a example i suggest you look up the functions used on php.net

Posted

its nice to know people are learning use php.net to learn away from mccodes to many people are locked to using the database class and $ir things

@bladewolf2010 - anything free should be changed and made better before going on your site after all you don't want a site like the 1000's already up...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...