insei Posted January 12, 2010 Share Posted January 12, 2010 Hello, im trying to use a function inside an echo but i get error. Cant seem to figure out the error. The code: <?php include("functions.php"); ?> <div id="center-box-wrapper"> <h2 class="box"><p>1v1 Offline Rankings</p></h2> <div id="center-box-main-container-padding"> <table class="standings_whole"> <tr> <td width='39px'>Pos</td> <td width='43px'>Rank</td> <td width='29px'>Nat</td> <td width='106px'>Character</td> <td width='159px'>Username</td> <td width='40px'>Points</td> <td width='71px'>Statistics</td> <td width='67px'>Win Ratio</td> </tr> <?php $results = mysql_query("SELECT * FROM ladder_users"); $pos = 0; while($row = mysql_fetch_array($results)) { $pos += 1; echo " <tr> <td width='39px'>#".$pos."</td> <td width='43px'><img class='standings' src='images/ranks/".$row['Rank'].".jpg' border='0' /></td> <td width='29px'><img class='standings' width='25px' height='17px' src='images/flags/".$row['Nationality'].".gif' border='0' alt='".$row['Nationality']."' /></td> <td width='106px'><img class='standings' src='images/characters/".$row['Mchar'].".jpg' border='0' /></td> <td width='159px'>".$row['Username']."</td> <td width='40px'>".$row['Points']."</td> <td width='71px'>".$row['Win']." - ".$row['Loss']."</td> <td width='67px'>".win_ratio($row['Win'],$row['Loss'])."%</td> </tr> "; } ?> </table> </div> <div id="center-box-bottom"> </div> </div> This is whats inside the functions.php : function win_ratio($win,$loss) { if ($loss == 0) { return 100; } else if ($win == 0) { return 0; } else { $ratio = (($win/($win+$loss))*100); return round($ratio, 2); } } Link to comment https://forums.phpfreaks.com/topic/188140-call-to-undefined-function/ Share on other sites More sharing options...
trq Posted January 12, 2010 Share Posted January 12, 2010 Obviously the file isn't being included. Change it to.... <?php require "functions.php"; ?> And make sure you have error_reporting set to E_ALL and display errors on. Link to comment https://forums.phpfreaks.com/topic/188140-call-to-undefined-function/#findComment-993285 Share on other sites More sharing options...
insei Posted January 12, 2010 Author Share Posted January 12, 2010 the file does get included , but just as a plain text.. its almost like it doenst realize its a function. I tried the require too http://www.xgs-gaming.com/tlt/files/ladder_system/index.php Link to comment https://forums.phpfreaks.com/topic/188140-call-to-undefined-function/#findComment-993292 Share on other sites More sharing options...
tail Posted January 12, 2010 Share Posted January 12, 2010 Does functions.php have <?php ?> tags? Link to comment https://forums.phpfreaks.com/topic/188140-call-to-undefined-function/#findComment-993295 Share on other sites More sharing options...
trq Posted January 12, 2010 Share Posted January 12, 2010 Does functions.php have <?php ?> tags? Does'nt look like it. PHP includes still require <?php tags. Link to comment https://forums.phpfreaks.com/topic/188140-call-to-undefined-function/#findComment-993296 Share on other sites More sharing options...
insei Posted January 12, 2010 Author Share Posted January 12, 2010 oh ofc! Thanks alot, the frustation is suddently gone ) Link to comment https://forums.phpfreaks.com/topic/188140-call-to-undefined-function/#findComment-993298 Share on other sites More sharing options...
tail Posted January 12, 2010 Share Posted January 12, 2010 You're welcome, glad to help. Link to comment https://forums.phpfreaks.com/topic/188140-call-to-undefined-function/#findComment-993306 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.