View previous topic :: View next topic |
Author |
Message |
senahsirap -
Joined: 13 Feb 2007 Posts: 2
|
Posted: Tue Feb 13, 2007 6:43 am Post subject: whats wrong with my php code? plz help me.. |
|
|
i wrote the php code to allow user change background color for the pages in my system. i display the color picker by using the javascript. but i faced some problem with the .php files.
Code: | file zz.php
<?php
$bgColor = $_POST['backColor'];
echo $bgColor;
?>
<link rel="stylesheet" type="text/css"
media="screen" href="style.php">
<script language="JavaScript">
function BtnOkClicked()
{
document.getElementById("bgCol".value = SEL_COLOR;
}
</script>
<html>
<body>
<form method="post" action="style.php?bg=000023">
<div class="divSection">
<br>BACKGROUND:<br>
Choose A color: <input type="text" id="bgCol" size="12"><input type="button" value="..." onclick="ShowLayer();"><BR>
<br><br>
<input name="change" type="submit" value="Change Now">
<!--COLOR PICKER WIDGET BEGIN -->
<div style="position:absolute;border:1px solid black;background-color:white;display:none;width:337px;height:375px;" id="main" imgLoc="./">
</div>
<script language="JavaScript" src="cpick.js"></script>
<!--COLOR PICKER WIDGET END -->
</form>
</body>
</html>
style.php
<?php
$id = $_GET['bg'];
echo $id;
$white = $id;
$dkgray = '#333444';
$dkgreen = '#008400';
?>
body {
background:<?=$white?>;
color:<?=$dkgray?>;
}
h1, h2, h3, h4 {
color:<?=$dkgreen?>;
}
blockquote {
color:<?=$dkgreen?>;
} |
i set the value of bg=#000032.in style.php. but it can't read the '#' sign. and the output that i got such as below:
body { background:; color:#333; } h1, h2, h3, h4 { color:#008400; } blockquote { color:#008400; }
then, i try to remove the #. i just assign bg=000023. but when i run the coding, the color still not change. the output is like this:
000023 body { background:#000023; color:#333; } h1, h2, h3, h4 { color:#008400; } blockquote { color:#008400; }
plzz help me. i had work on it but still can't find where is the error. and thanks in advance :oops: |
|
Back to top |
|
 |
pkSML -
Joined: 29 May 2006 Posts: 955 Location: Michigan, USA
|
Posted: Tue Feb 13, 2007 11:14 pm Post subject: |
|
|
Try not entering the # in the variable. Just put it in the HTML code instead.
example:
$dkgreen = "008400";
color: #<?=$dkgreen?>;
PS You might try turning on error reporting in PHP.
Code: | error_reporting(2047); |
_________________ Stephen
Need a LitlURL?
http://CodeBin.yi.org |
|
Back to top |
|
 |
AbyssUnderground -
Joined: 31 Dec 2004 Posts: 3855
|
Posted: Tue Feb 13, 2007 11:35 pm Post subject: |
|
|
Code: | color:<?=$dkgreen?>; |
Does that even work? Id expect it to be
Code: | color:<?php echo($dkgreen); ?> |
_________________ Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk |
|
Back to top |
|
 |
senahsirap -
Joined: 13 Feb 2007 Posts: 2
|
Posted: Wed Feb 14, 2007 2:57 am Post subject: |
|
|
had changed the code like u said. but the color still didn't change. this is the output i got:-
F00023 body { background: #F00023; color:333; } h1, h2, h3, h4 { color:008400; } blockquote { color:008400; }
i think the problem is with $id variable
when i try to change $white = '$id'; read $id as a text. this is the output:-
F00023 body { background: #$id; color:333; } h1, h2, h3, h4 { color:008400; } blockquote { color:008400; }
i only can get the ouput if i set the color value in the $white variable. for eg:- $white = 'F50021';
but i want to bring the value from the previous page, which is from page zz.php |
|
Back to top |
|
 |
|