Jump to content

[SOLVED] help.


seany123

Recommended Posts

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?

 

Link to comment
Share on other sites

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...

 

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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>";

 

 

 

 

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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??

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.