dynamicgfx Posted June 8, 2012 Share Posted June 8, 2012 Need help with the code below it gives a fatal error <? $result = mysql_query("SELECT * FROM topics WHERE id='$id'"); while($row = mysql_fetch_array($result)) { $des = $row['desc']; ?> <? function replacesmiley($des) { $des = str_replace('', '<img src="set1/biggrin.gif" alt="" />', $des); $des = str_replace('', '<img src="set1/biggrin.gif" alt="" />', $des); $des = str_replace('', '<img src="set1/sad.gif" alt="" />', $des); $des = str_replace('', '<img src="set1/001_smile.gif" alt="" />', $des); $des = str_replace('', '<img src="set1/tongue_smilie.gif" alt="" />', $des); $des = str_replace('', '<img src="set1/tongue_smilie.gif" alt="" />', $des); return $des; } ?> <table width="100%" border="1" cellpadding="0" cellspacing="0" style="border:thin; border-top:none;"> <tr style="color:#FFF;"> <th width="30%" bgcolor="#000000" scope="col"></th> <th width="70%" bgcolor="#000000" scope="col"><? echo $row['name']; ?></th> </tr> <tr height="50px" style="text-align:center; background:url(http://k-rs.co.uk/images/background.png);"> <td><? echo $row['user']; ?><br /><? echo $row['post']; ?></td> <td><? echo replacesmiley($des) ?></td> </tr> <? $server = mysql_query("SELECT * FROM reply WHERE topic='$id'"); while($rows = mysql_fetch_array($server)) { $user = $rows['user']; $desc = $rows['desc']; ?> <? function replace($desc) { $desc = str_replace('', '<img src="set1/biggrin.gif" alt="" />', $desc); $desc = str_replace('', '<img src="set1/sad.gif" alt="" />', $desc); $desc = str_replace('', '<img src="set1/001_smile.gif" alt="" />', $desc); $desc = str_replace('', '<img src="set1/tongue_smilie.gif" alt="" />', $desc); return $desc; } ?> </tr> <tr height="50px" style="text-align:center; background:url(http://k-rs.co.uk/images/background.png);"> <td><? echo $rows['user']; ?><br /><? echo $rows['rank']; ?><br />Posted at: <? echo $rows['post']; ?></td> <td><? echo replace($desc) ?></td> </tr> <? }} ?> Quote Link to comment https://forums.phpfreaks.com/topic/263871-need-help-functions/ Share on other sites More sharing options...
scootstah Posted June 8, 2012 Share Posted June 8, 2012 What is the error? Quote Link to comment https://forums.phpfreaks.com/topic/263871-need-help-functions/#findComment-1352235 Share on other sites More sharing options...
dynamicgfx Posted June 8, 2012 Author Share Posted June 8, 2012 What is the error? Fatal error: Cannot redeclare replace() (previously declared in /home/a7749307/public_html/forum/topic.php:169) in /home/a7749307/public_html/forum/topic.php on line 169 thats the error to see it http://k-rs.co.uk/forum/topic.php?id=9 Quote Link to comment https://forums.phpfreaks.com/topic/263871-need-help-functions/#findComment-1352246 Share on other sites More sharing options...
ignace Posted June 8, 2012 Share Posted June 8, 2012 My guess would be "Cannot redeclare function replacesmiley()" move the smiley function out of the while() loop. EDIT: OP beat me to it. Quote Link to comment https://forums.phpfreaks.com/topic/263871-need-help-functions/#findComment-1352247 Share on other sites More sharing options...
dynamicgfx Posted June 8, 2012 Author Share Posted June 8, 2012 My guess would be "Cannot redeclare function replacesmiley()" move the smiley function out of the while() loop. EDIT: OP beat me to it. thanks it works now Quote Link to comment https://forums.phpfreaks.com/topic/263871-need-help-functions/#findComment-1352251 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.