frozenmafia Posted June 9, 2010 Share Posted June 9, 2010 Ok so I am coding a game from a GRPG framework. And I get this error: Fatal error: Cannot redeclare gradient() (previously declared in /home/frozen01/public_html/classeswgradients.php:759) in /home/frozen01/public_html/classeswgradients.php on line 759. Here is line 759 with the surrounding lines. $hexresult = mysql_query("SELECT * FROM `grpgusers` WHERE id='".$this->id."'") or die(mysql_error()); $hex = mysql_fetch_array($hexresult); if ($hex['hexname'] == 1){ $result = mysql_query("SELECT * FROM `grpgusers` WHERE id='".$this->id."'"); $worked = mysql_fetch_array($result); function gradient($text){ /*** initialize the return string ***/ $ret = ''; /*** an array of colors ***/ $colors = array( $worked['hex1'], $worked['hex2'], $worked['hex3'] ); /*** a counter ***/ $i = 0; /*** get the length of the text ***/ $textlength = strlen($text); /*** a line of text ***/ $text = $this->username; /*** loop over the text ***/ while($i<=$textlength) { /*** loop through the colors ***/ foreach($colors as $value) { if ($text[$i] != "") { $ret .= '<span style="color:#'.$value.';">'.$this->$username[$i]."</span>"; } $i++; } } /*** return the highlighted string ***/ return $ret; } } Link to comment https://forums.phpfreaks.com/topic/204300-cannot-redefine-gradient/ Share on other sites More sharing options...
premiso Posted June 9, 2010 Share Posted June 9, 2010 You should check out this tutorial: http://www.phpfreaks.com/tutorial/defining-a-php-function-only-once Link to comment https://forums.phpfreaks.com/topic/204300-cannot-redefine-gradient/#findComment-1069994 Share on other sites More sharing options...
frozenmafia Posted June 9, 2010 Author Share Posted June 9, 2010 Thanks pal but now I get: Fatal error: Using $this when not in object context in /home/frozen01/public_html/classeswgradients.php on line 777. see above for code. 776 /*** a line of text ***/ 777 $text = $this->username; Link to comment https://forums.phpfreaks.com/topic/204300-cannot-redefine-gradient/#findComment-1070009 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.