Jump to content


Photo

Variable not keeping value?


  • Please log in to reply
3 replies to this topic

#1 KDragon

KDragon
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 23 April 2006 - 04:59 AM

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


#2 mb81

mb81
  • Members
  • PipPipPip
  • Advanced Member
  • 120 posts

Posted 23 April 2006 - 05:31 AM

[!--quoteo(post=367613:date=Apr 23 2006, 12:59 AM:name=KDragon)--][div class=\'quotetop\']QUOTE(KDragon @ Apr 23 2006, 12:59 AM) View Post[/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:
<?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>
[/quote]

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

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

and it should work.


#3 KDragon

KDragon
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 23 April 2006 - 05:35 AM

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

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

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.

#4 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 23 April 2006 - 05:36 AM

Unless you change the backgroud-color of the body, this text will not be seen.

Ken




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users