Call to undefined function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
insei
Forum Newbie
Posts: 5
Joined: Mon Jan 11, 2010 9:57 pm

Call to undefined function

Post by insei »

Hello, i cant seem to find the error in this code..

http://www.xgs-gaming.com/tlt/files/lad ... /index.php



<?php

include("functions.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>
";


}

?>


This is whats inside 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);
}
}
User avatar
SimpleManWeb
Forum Commoner
Posts: 57
Joined: Wed Dec 30, 2009 4:15 pm
Location: New Hampshire, USA

Re: Call to undefined function

Post by SimpleManWeb »

Change your include (functions.php) to require (functions.php). I bet you will find that the file is not being included. I couldn't find any errors in your code, so it has to be that it isn't getting the file correctly.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Call to undefined function

Post by requinix »

insei wrote:Hello, i cant seem to find the error in this code..
And you want us to do it for you? You going to give us something to start from?
insei
Forum Newbie
Posts: 5
Joined: Mon Jan 11, 2010 9:57 pm

Re: Call to undefined function

Post by insei »

tasairis wrote:
insei wrote:Hello, i cant seem to find the error in this code..
And you want us to do it for you? You going to give us something to start from?
im sorry my bad... I was stupid enough to forget the php tags inside the functions.php.

Thanks alot for the replies, really apriciate it.
Post Reply