June 11, 200719 yr I was trying to create a dynamic color selector using php.... I uploaded it here: http://www.theneopianoutpost.com/new/index.php I get this error: Parse error: parse error, unexpected T_STRING in /home/content/I/n/d/Individual12/html/new/index.php on line 29 Heres my coding: (Note: Do not try to figure this out if you don't know php or else you'll hurt your head :P) <?php function hsb( $h, $s, $v ) { $r = $g = $b =0; if ( $s==0 ) { $r = $g = $b =$v; } else { $h = $h / 60; $i = floor( $h ); $f = $h - $i; $p = $v * ( 1 - $s ); $q = $v * ( 1 - $s * $f ); $t = $v * ( 1 - $s * ( 1 - $f ) ); switch( $i ) { case o: $r = $v; $g = $t; $b = $p; break; case 1: $r = $q; $g = $v; $b = $p; break; case 2: $r = $p; $g = $v; $b = $t; break; case 3: $r = $p; $g = $q; $b = $v; break; case 4: $r = $t; $g = $p; $b = $v; break; default: $r = $v; $g = $p; $b = $q; break; } } return array( $r, $g, $b ); } functiom hsb2hex( $h, $s, $b ) { list( $r, $g, $b ) = hsb( $h, $s, $b ); return sprintf( "#%02x%02x%02x", $r, $g, $b ); } ?> <html> <head> <script language="Javascript"> function mover( id ) { var obj = document.getElementById( id ); obj.style.borderColor = "white"; } function mout( id ) { var obj = document.getElementById( id ); obj.style.borderColor = "black"; } function selectColor( color ) { document.getElementById( "hoverColor" ).innerHTML = color; } </script> <style type="text/css"> body { font family: arial, verdana, sans-serif; } #color { font-family: courier } #hoverColor { font-family: courier; } </style> </head> <body> Color: <input id="color" type="text" size="8" /> <table cellspacing="10" cellpadding="0"><tr><td> <table cellspacing="0" cellpadding="0"> <?php $id = 1; for( $h = 0; $h < 360; $h += 18 ) { ?> <tr> <?php for( $b = 255; $b >= 0; $b -= 10 ) { $color = hsb2hex( $h, $b / 255, $b ); ?> <td> <div id="cp<?php echo( $id ); ?>" style="height:10px; width:10px; border: 1px solid white; background:<?php echo( $color ); ?>;" onmouseover="mover('cp<?php echo( $id ); ?>');hover('<?php echo( $color ); ?>');" onmouseout="mout('cp<?php echo( $id ); ?>')" onclick="selectColor('<?php echo( $color ); ?>');"</div> </td> <?php $id += 1; } ?> </tr> <?php } ?> </table> </td><td valign="top"> <div id="hoverColor"></div> </td></tr></table> </body> </html> Any ideas why its not working? Thanks.....and good luck! :yes:
June 11, 200719 yr Error on line 29... which is : functiom hsb2hex( $h, $s, $b ) and should be function hsb2hex( $h, $s, $b ) so just a typing error, I think...
June 16, 200719 yr I'm curious. I use frontpage and I followed a tutorial on another website on how to use PHP with FP, but it didn't work. What program are you using to code your PHP?
June 26, 200719 yr Author I write my php on notepad and use SmartFTP to upload it... D'oh! Thanks for the help Angelxepha! ((stupid typo <_<))
June 26, 200719 yr You are welcome Zac :P And usually, well, I dont code much in PHP... but I would do it in notepad or viewing source code in dreamweaver...
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.