Jump to content

Archived

This topic is now archived and is closed to further replies.

KDragon

Variable not keeping value?

Recommended Posts

Why isn't the text this document displays, white? I have a variable representing each value of the rgb specification of the color white. I set the variable to 255 but the text always shows up black. Can anybody please explain why? Here's the code:
[code]<?php $colorNum=255; ?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<p style="color: rgb(<?php $colorNum; ?>,<?php $colorNum; ?>,<?php $colorNum; ?>);">This be some text.</p>
</body>
</html>
[/code]

Share this post


Link to post
Share on other sites
[!--quoteo(post=367613:date=Apr 23 2006, 12:59 AM:name=KDragon)--][div class=\'quotetop\']QUOTE(KDragon @ Apr 23 2006, 12:59 AM) [snapback]367613[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Why isn't the text this document displays, white? I have a variable representing each value of the rgb specification of the color white. I set the variable to 255 but the text always shows up black. Can anybody please explain why? Here's the code:
[code]<?php $colorNum=255; ?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<p style="color: rgb(<?php $colorNum; ?>,<?php $colorNum; ?>,<?php $colorNum; ?>);">This be some text.</p>
</body>
</html>
[/code]
[/quote]

My bet would be that if you view the source of the file, it will look like this:
[code]
<p style="color: rgb(,,);">This be some text.</p>
[/code]

Change your line to this:
[code]
<p style="color: rgb(<?php echo $colorNum; ?>,<?php echo $colorNum; ?>,<?php echo $colorNum; ?>);">This be some text.</p>
[/code]

and it should work.

Share this post


Link to post
Share on other sites
[!--quoteo(post=367618:date=Apr 23 2006, 01:31 AM:name=mb81)--][div class=\'quotetop\']QUOTE(mb81 @ Apr 23 2006, 01:31 AM) [snapback]367618[/snapback][/div][div class=\'quotemain\'][!--quotec--]
My bet would be that if you view the source of the file, it will look like this:
[code]
<p style="color: rgb(,,);">This be some text.</p>
[/code]

Change your line to this:
[code]
<p style="color: rgb(<?php echo $colorNum; ?>,<?php echo $colorNum; ?>,<?php echo $colorNum; ?>);">This be some text.</p>
[/code]

and it should work.
[/quote]


Oh gosh I'm dumb. I'm sorry :(. My brain must be totally just ahhh today. Thank you for your help.

Share this post


Link to post
Share on other sites
Unless you change the backgroud-color of the body, this text will not be seen.

Ken

Share this post


Link to post
Share on other sites

×

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.