Jump to content

Recommended Posts

<?php
session_start();
include "includes/db_connect.php";
include "includes/functions.php";
logincheck();
$username=$_SESSION['username'];

$fetch=mysql_fetch_object(mysql_query("SELECT * FROM users WHERE username='$username'"));


$currank=$fetch->rank;
$rankp = $fetch->rankpoints;


if ($currank == "Tramp"){
$max = '350';
$old="1";

}elseif ($currank == "Theif"){
$max = '750';
$old="350";

}elseif ($currank == "Hooligan"){
$max = '2320';
$old="750";

}elseif ($currank == "Criminal"){
$max = '4000';
$old="2320";

}elseif ($currank == "Gangster"){
$max = '6000';
$old="4000";

}elseif ($currank == "Boss"){
$max = '7200';
$old="6000";

}elseif ($currank == "Supreme Boss"){
$max = '11500';
$old="7200";

}
elseif ($currank == "Don"){
$max = '17200';
$old="11500";

}
elseif ($currank == "Legendary Don"){
$max = '150000';
$old="17200";

}
elseif ($currank == "Mod"){
$max = '17048';
$old="1";
}
elseif ($currank == "Admin"){
$max = '17048';
$old="1";
}
elseif ($currank == "Owner"){
$max = '17048';
$old="1";
}
$percent = round((($rankp-$old)/($max-$old))*100, 1);

$check = mysql_query("SELECT * FROM `inbox` WHERE `read`='0' AND `to`='$username'");
$inbox=mysql_num_rows($check);
?>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
	<title></title>
	<link href="includes/marquee.css" rel="stylesheet" type="text/css" />
	<script src="includes/marquee.js" type="text/javascript"></script>

</head>   
<body dir="ltr">
	<div id="marquee">
		<div><a href="inbox.php" target="middle">Rank: <?php echo "$fetch->rank"; ?> | Money: <?php echo "£".makecomma($fetch->money).""; ?> | Location: <?php echo "$fetch->location"; ?> | Health: <?php echo "$fetch->health"; ?>% | Points: <?php echo "$fetch->points"; ?> | Crew: <?php if ($fetch->crew == "0"){ echo "None"; }else{ echo "$fetch->crew"; } ?> | Bullets: <?php echo "".makecomma($fetch->bullets).""; ?> | Inbox: <?php if ($inbox > 0 ) { echo "$inbox New message(s)."; } else {echo "No new messages."; } ?></a></div>
	</div>

</body>
</html>

Do this:

 

if ($max-$old == 0) {
   die("Error these two equal 0 Max: " . $max . " Old: " . $old . " Equals: " . ($max - $old));
}else {
   $percent = round((($rankp-$old)/($max-$old))*100, 1);
}

 

And see what displays/report back. I bet that $max and $old are not hitting any of the if statements, thus they do not have a value which in return would give the division by zero error. If you can have a default value for $max and $old I would set that in your script before the if's or set it as an else at the end of the if's so this error does not happen if the $currank is not apart of any of the if's.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.