whats wrong with my php code? plz help me..

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
senahsirap
-


Joined: 13 Feb 2007
Posts: 2

PostPosted: Tue Feb 13, 2007 6:43 am    Post subject: whats wrong with my php code? plz help me.. Reply with quote

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 View user's profile Send private message
pkSML
-


Joined: 29 May 2006
Posts: 955
Location: Michigan, USA

PostPosted: Tue Feb 13, 2007 11:14 pm    Post subject: Reply with quote

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 View user's profile Send private message Visit poster's website
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Tue Feb 13, 2007 11:35 pm    Post subject: Reply with quote

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 View user's profile Send private message Visit poster's website
senahsirap
-


Joined: 13 Feb 2007
Posts: 2

PostPosted: Wed Feb 14, 2007 2:57 am    Post subject: Reply with quote

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 View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group