seany123 Posted May 12, 2009 Share Posted May 12, 2009 i am using this echo... echo "<b><font color=\"" .$player->ncolorid. "\>".$player->username."</font></b>"; ncolorid is a varchar. my problem is... if i put say the word "white" as the value of ncolorid... the above will echo in a blue color!! im like wtf. anyone know why this is happening? Quote Link to comment https://forums.phpfreaks.com/topic/157867-solved-help/ Share on other sites More sharing options...
Ken2k7 Posted May 12, 2009 Share Posted May 12, 2009 And what do you get if you put yellow instead? Quote Link to comment https://forums.phpfreaks.com/topic/157867-solved-help/#findComment-832667 Share on other sites More sharing options...
allworknoplay Posted May 12, 2009 Share Posted May 12, 2009 You're escaping the tag, not the double quotes....try this... echo "<b><font color=\"" .$player->ncolorid. "\">".$player->username."</font></b>"; Quote Link to comment https://forums.phpfreaks.com/topic/157867-solved-help/#findComment-832669 Share on other sites More sharing options...
seany123 Posted May 12, 2009 Author Share Posted May 12, 2009 And what do you get if you put yellow instead? i put in "Yellow" and the echo came out in black Quote Link to comment https://forums.phpfreaks.com/topic/157867-solved-help/#findComment-832670 Share on other sites More sharing options...
Ken2k7 Posted May 12, 2009 Share Posted May 12, 2009 THAT IS AWESOME! I didn't know that trick. Quote Link to comment https://forums.phpfreaks.com/topic/157867-solved-help/#findComment-832671 Share on other sites More sharing options...
seany123 Posted May 12, 2009 Author Share Posted May 12, 2009 You're escaping the tag, not the double quotes....try this... echo "<b><font color=\"" .$player->ncolorid. "\">".$player->username."</font></b>"; that seems to have fixed this problem... why exactly was it doing that? Quote Link to comment https://forums.phpfreaks.com/topic/157867-solved-help/#findComment-832672 Share on other sites More sharing options...
allworknoplay Posted May 12, 2009 Share Posted May 12, 2009 You're escaping the tag, not the double quotes....try this... echo "<b><font color=\"" .$player->ncolorid. "\">".$player->username."</font></b>"; that seems to have fixed this problem... why exactly was it doing that? It wasn't doing anything, you're the one that escaped the wrong character...LOL.. Anyways, when you don't provide the font color what it's looking for, it just guesses the color... I like to used hex colors so I know exactly what the color will be. Also, font color is really the old way to do things. Look into using SPAN tags to change your font colors... Quote Link to comment https://forums.phpfreaks.com/topic/157867-solved-help/#findComment-832680 Share on other sites More sharing options...
seany123 Posted May 12, 2009 Author Share Posted May 12, 2009 You're escaping the tag, not the double quotes....try this... echo "<b><font color=\"" .$player->ncolorid. "\">".$player->username."</font></b>"; that seems to have fixed this problem... why exactly was it doing that? It wasn't doing anything, you're the one that escaped the wrong character...LOL.. Anyways, when you don't provide the font color what it's looking for, it just guesses the color... I like to used hex colors so I know exactly what the color will be. Also, font color is really the old way to do things. Look into using SPAN tags to change your font colors... the idea of what im trying to do is allow members to change their usernames font color. using their database entry Quote Link to comment https://forums.phpfreaks.com/topic/157867-solved-help/#findComment-832696 Share on other sites More sharing options...
allworknoplay Posted May 12, 2009 Share Posted May 12, 2009 the idea of what im trying to do is allow members to change their usernames font color. using their database entry Go for it, I see no reason why not? Just make sure they don't change it to white when there's a white background. haha.... Quote Link to comment https://forums.phpfreaks.com/topic/157867-solved-help/#findComment-832699 Share on other sites More sharing options...
Ken2k7 Posted May 12, 2009 Share Posted May 12, 2009 Or red because that can be misleading. Quote Link to comment https://forums.phpfreaks.com/topic/157867-solved-help/#findComment-832702 Share on other sites More sharing options...
seany123 Posted May 12, 2009 Author Share Posted May 12, 2009 why would red be misleading?? another thing when doing it this way it wont work... echo "<b><font color=\"" .$profile['ncolorid']. "\">".$profile['username']."</font></b>"; Quote Link to comment https://forums.phpfreaks.com/topic/157867-solved-help/#findComment-832704 Share on other sites More sharing options...
allworknoplay Posted May 12, 2009 Share Posted May 12, 2009 hmm...what if you tried it this way: echo "<b><font color=\"$profile['ncolorid']\">$profile['username']</font></b>"; Quote Link to comment https://forums.phpfreaks.com/topic/157867-solved-help/#findComment-832713 Share on other sites More sharing options...
seany123 Posted May 12, 2009 Author Share Posted May 12, 2009 i get this error. Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING Quote Link to comment https://forums.phpfreaks.com/topic/157867-solved-help/#findComment-832728 Share on other sites More sharing options...
allworknoplay Posted May 12, 2009 Share Posted May 12, 2009 i get this error. Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING Oh my bad, you introduced the single quotes that's why...you have to escape those too.. try: echo "<b><font color=\"$profile[\'ncolorid\']\">$profile[\'username\']</font></b>"; But seriously, it's a lot easier and cleaner to do it this way: $username = $profile['username']; $color = $profile['ncolorid']; echo "<b><font color=\"$color\">$username</font></b>"; Quote Link to comment https://forums.phpfreaks.com/topic/157867-solved-help/#findComment-832733 Share on other sites More sharing options...
Ken2k7 Posted May 12, 2009 Share Posted May 12, 2009 What do this print out - var_dump($profile['username']); var_dump($profile['ncolorid']); Quote Link to comment https://forums.phpfreaks.com/topic/157867-solved-help/#findComment-832740 Share on other sites More sharing options...
seany123 Posted May 12, 2009 Author Share Posted May 12, 2009 i get this error. Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING Oh my bad, you introduced the single quotes that's why...you have to escape those too.. try: echo "<b><font color=\"$profile[\'ncolorid\']\">$profile[\'username\']</font></b>"; But seriously, it's a lot easier and cleaner to do it this way: $username = $profile['username']; $color = $profile['ncolorid']; echo "<b><font color=\"$color\">$username</font></b>"; i tried using the $username = $profile['username']; $color = $profile['ncolorid']; echo "<b><font color=\"$color\">$username</font></b>"; however its gone back to echoing the wrong color. Quote Link to comment https://forums.phpfreaks.com/topic/157867-solved-help/#findComment-832742 Share on other sites More sharing options...
allworknoplay Posted May 12, 2009 Share Posted May 12, 2009 Print out the colors to make sure you are getting the right colors. Also, you might have to trim the results, you could have whitespace maybe? Quote Link to comment https://forums.phpfreaks.com/topic/157867-solved-help/#findComment-832745 Share on other sites More sharing options...
seany123 Posted May 12, 2009 Author Share Posted May 12, 2009 Print out the colors to make sure you are getting the right colors. Also, you might have to trim the results, you could have whitespace maybe? what do you mean by whitespace? Quote Link to comment https://forums.phpfreaks.com/topic/157867-solved-help/#findComment-832765 Share on other sites More sharing options...
Ken2k7 Posted May 12, 2009 Share Posted May 12, 2009 seany123, see my post previous to this one. Quote Link to comment https://forums.phpfreaks.com/topic/157867-solved-help/#findComment-832767 Share on other sites More sharing options...
seany123 Posted May 12, 2009 Author Share Posted May 12, 2009 What do this print out - var_dump($profile['username']); var_dump($profile['ncolorid']); this is what i get: string(9) "adminsean" NULL adminsean is my username. Quote Link to comment https://forums.phpfreaks.com/topic/157867-solved-help/#findComment-832772 Share on other sites More sharing options...
Ken2k7 Posted May 12, 2009 Share Posted May 12, 2009 Apparently $profile['ncolorid'] is NULL. Is your SQL correct? Quote Link to comment https://forums.phpfreaks.com/topic/157867-solved-help/#findComment-832774 Share on other sites More sharing options...
seany123 Posted May 12, 2009 Author Share Posted May 12, 2009 no my ncolorid is red. Quote Link to comment https://forums.phpfreaks.com/topic/157867-solved-help/#findComment-832777 Share on other sites More sharing options...
seany123 Posted May 12, 2009 Author Share Posted May 12, 2009 i get this error. Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING Oh my bad, you introduced the single quotes that's why...you have to escape those too.. try: echo "<b><font color=\"$profile[\'ncolorid\']\">$profile[\'username\']</font></b>"; But seriously, it's a lot easier and cleaner to do it this way: $username = $profile['username']; $color = $profile['ncolorid']; echo "<b><font color=\"$color\">$username</font></b>"; doing it this way... echo "<b><font color=\"$profile[\'ncolorid\']\">$profile[\'username\']</font></b>"; get this error.... Parse error: syntax error, unexpected T_BAD_CHARACTER, expecting T_STRING or T_VARIABLE or T_NUM_STRING Quote Link to comment https://forums.phpfreaks.com/topic/157867-solved-help/#findComment-832785 Share on other sites More sharing options...
Ken2k7 Posted May 12, 2009 Share Posted May 12, 2009 I'm telling you, $profile['ncolorid'] is NULL. var_dump says so, not me. You may want to check your DB to make sure ncolorid has the color and is not null. Quote Link to comment https://forums.phpfreaks.com/topic/157867-solved-help/#findComment-832794 Share on other sites More sharing options...
seany123 Posted May 12, 2009 Author Share Posted May 12, 2009 I'm telling you, $profile['ncolorid'] is NULL. var_dump says so, not me. You may want to check your DB to make sure ncolorid has the color and is not null. i understand what your saying.. but using this echo it works fine... echo "<b><font color=\"" .$player->ncolorid. "\">".$player->username."</font></b>"; how does it know what color to echo if the ncolorid value is null?? Quote Link to comment https://forums.phpfreaks.com/topic/157867-solved-help/#findComment-832814 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.