Jump to content

Variable not keeping value?


KDragon

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]
Link to comment
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.
Link to comment
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.
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.