Jump to content

This confuses me sooo much!


morbid angel911

Recommended Posts

$0 [

Warning: Division by zero in /home/mintcity/public_html/v2/inc.cartel.buy.php on line 44

0]

 

<td width="15%"><b><font size="1" face="Verdana, Arial, Helvetica">$<? echo number_format($myrowcs[price]) ?> [<font size="1" face="Verdana, Arial, Helvetica" color="#FFC000"><u><? echo floor(($myrow2b[money] / $myrowcs[price])); ?></u></font>]</font></b></td>

 

This is my code on line 44.  Any help would be greatly appreciated.

Link to comment
Share on other sites

The best thing you can do to find out is to remove

echo floor(($myrow2b[money] / $myrowcs[price])); 

and leave it like this:

<td width="15%"><b><font size="1" face="Verdana, Arial, Helvetica">$<? echo number_format($myrowcs[price]) ?> [<font size="1" face="Verdana, Arial, Helvetica" color="#FFC000"><u></u></font>]</font></b></td>

to see what the value of that variable is

Link to comment
Share on other sites

and also if you did use the code i told you and got nothing it means that the variable is empty which means that you cannot divide by nothing (0) so that is why you get the error! try to find out why the variable gets no value or the value zero

Link to comment
Share on other sites

<?

$cid = $myrow[cid];

?>

<form action="cartel.buyitems.submit.php?uid=<? echo $uid ?>&secid=<? echo $secid ?>" method="POST" enctype="application/x-www-form-urlencoded">

<table border="0" width="100%">

<tr>

<td width="10%"><p align="CENTER"><b><font size="1" face="Verdana, Arial, Helvetica">QTY</font></b></td>

<td width="15%"><b><font size="1" face="Verdana, Arial, Helvetica">ITEM</font></b></td>

<td width="35%"><b><font size="1" face="Verdana, Arial, Helvetica">DESCRIPTION</font></b></td>

<td width="15%"><b><font size="1" face="Verdana, Arial, Helvetica">PRICE</font></b></td>

<td width="25%"><p align="RIGHT"><b><font size="1" face="Verdana, Arial, Helvetica">YOU HAVE</font></b></td>

</tr>

<?

 

$sql2b = "SELECT money from og_cartelinfo where id=$cid";

 

@mysql_connect($dbhost,  $dbuser,  $dbpass);

 

@mysql_select_db($dbname) or die("Error opening database");

 

$result2b = @mysql_query($sql2b);

$myrow2b = @mysql_fetch_array($result2b);

 

 

$sqlcs = "SELECT * from og_cartelrates where buy=1 order by id";

 

@mysql_connect($dbhost,  $dbuser,  $dbpass);

@mysql_select_db($dbname) or die("Error opening database");

 

 

$resultcs = @mysql_query($sqlcs);

$myrowcs = @mysql_fetch_array($resultcs);

 

do {

?>

<tr>

<td width="10%">

<center>

<p><input type="TEXT" name="item[<? echo $myrowcs[id] ?>]" size="4" style="Font-Family : Verdana, Arial, Helvetica ; Font-Size : 7pt">

</center>

</td>

<td width="15%"><b><font size="1" face="Verdana, Arial, Helvetica"><? echo $myrowcs[item_name] ?></font></b></td>

<td width="35%"><b><font size="1" face="Verdana, Arial, Helvetica"><? echo $myrowcs[description] ?></font></b></td>

<td width="15%"><b><font size="1" face="Verdana, Arial, Helvetica">$<? echo number_format($myrowcs[price]) ?> [<font size="1" face="Verdana, Arial, Helvetica" color="#FFC000"><u><? echo floor(($myrow2b[money] / $myrowcs[price])); ?></u></font>]</font></b></td>

<?

$product = $myrowcs[product];

$sql2 = "SELECT $product from og_cartelinfo where id=$cid";

 

@mysql_connect($dbhost,  $dbuser,  $dbpass);

 

@mysql_select_db($dbname) or die("Error opening database");

 

$result2 = @mysql_query($sql2);

$myrow2 = @mysql_fetch_array($result2);

?>

<td width="25%">

<p align="RIGHT"><b><font size="1" face="Verdana, Arial, Helvetica"><? echo number_format($myrow2[$product]) ?></font></b>

</td>

</tr>

<?

} while ($myrowcs = @mysql_fetch_array($resultcs));

?>

<?

if ($case) {

?>

<tr>

<td colspan="5"><br>

<center><b><font size="2" face="Verdana, Arial, Helvetica">Whatcha doin foo? You ain't got enuff cash!</font></b></center>

</td>

</tr>

<?

}

?>

<tr>

<td colspan="5"><br>

<br>

<center><b><font size="1" face="Verdana, Arial, Helvetica">You have $<? echo number_format($myrow2b[money]) ?> to spend!</font></b></center><br><br>

<input type="hidden" name="cid" value="<? echo $cid ?>">

<center><input type="submit" name="buy items" style="Font-Family : Verdana, Arial, Helvetica ; Font-Size : 7pt"></center>

</td>

</tr>

</table>

</form>

 

This is the entire code.  You don't think it would have something to do with my database do you?

Link to comment
Share on other sites

Try it now and let me now if it works so i can explain what was wrong

<?
         $cid = $myrow[cid];
?>
         <form action="cartel.buyitems.submit.php?uid=<? echo $uid ?>&secid=<? echo $secid ?>" method="POST" enctype="application/x-www-form-urlencoded">
         <table border="0" width="100%">
            <tr>
               <td width="10%"><p align="CENTER"><b><font size="1" face="Verdana, Arial, Helvetica">QTY</font></b></td>
               <td width="15%"><b><font size="1" face="Verdana, Arial, Helvetica">ITEM</font></b></td>
               <td width="35%"><b><font size="1" face="Verdana, Arial, Helvetica">DESCRIPTION</font></b></td>
               <td width="15%"><b><font size="1" face="Verdana, Arial, Helvetica">PRICE</font></b></td>
               <td width="25%"><p align="RIGHT"><b><font size="1" face="Verdana, Arial, Helvetica">YOU HAVE</font></b></td>
            </tr>
<?

               $sql2b = "SELECT `money` from `og_cartelinfo` where `id`='$cid'";
      
               @mysql_connect($dbhost,  $dbuser,  $dbpass) or die("Error connecting to database");

               @mysql_select_db($dbname) or die("Error opening database");

               $result2b = @mysql_query($sql2b);
               $myrow2b = @mysql_fetch_array($result2b);

               
         $sqlcs = "SELECT * from `og_cartelrates` where `buy`='1' order by `id`";

        


         $resultcs = @mysql_query($sqlcs);
         $myrowcs = @mysql_fetch_array($resultcs);
         
         do {
?>
            <tr>
               <td width="10%">
                  <center>
                  <p><input type="TEXT" name="item[<? echo $myrowcs[id] ?>]" size="4" style="Font-Family : Verdana, Arial, Helvetica ; Font-Size : 7pt">
                  </center>
               </td>
               <td width="15%"><b><font size="1" face="Verdana, Arial, Helvetica"><? echo $myrowcs[item_name] ?></font></b></td>
               <td width="35%"><b><font size="1" face="Verdana, Arial, Helvetica"><? echo $myrowcs[description] ?></font></b></td>
               <td width="15%"><b><font size="1" face="Verdana, Arial, Helvetica">$<? echo number_format($myrowcs[price]) ?> [<font size="1" face="Verdana, Arial, Helvetica" color="#FFC000"><u><? echo floor(($myrow2b[money] / $myrowcs[price])); ?></u></font>]</font></b></td>
               <?
               $product = $myrowcs[product];
               $sql2 = "SELECT `product` from `og_cartelinfo` where `id`='$cid'";
      
               

               $result2 = @mysql_query($sql2);
               $myrow2 = @mysql_fetch_array($result2);
               ?>
               <td width="25%">
                  <p align="RIGHT"><b><font size="1" face="Verdana, Arial, Helvetica"><? echo number_format($myrow2[$product]) ?></font></b>
               </td>
            </tr>
<?
            } while ($myrowcs = @mysql_fetch_array($resultcs));
?>
<?
if ($case) {
?>
            <tr>
               <td colspan="5"><br>
               <center><b><font size="2" face="Verdana, Arial, Helvetica">Whatcha doin foo? You ain't got enuff cash!</font></b></center>
               </td>
            </tr>
<?
}
?>
            <tr>
               <td colspan="5"><br>
<br>
               <center><b><font size="1" face="Verdana, Arial, Helvetica">You have $<? echo number_format($myrow2b[money]) ?> to spend!</font></b></center><br><br>
               <input type="hidden" name="cid" value="<? echo $cid ?>">
               <center><input type="submit" name="buy items" style="Font-Family : Verdana, Arial, Helvetica ; Font-Size : 7pt"></center>
               </td>
            </tr>
         </table>
         </form>

Link to comment
Share on other sites

Try this and tell me if you get anything there

<?
         $cid = $myrow[cid];
?>
         <form action="cartel.buyitems.submit.php?uid=<? echo $uid ?>&secid=<? echo $secid ?>" method="POST" enctype="application/x-www-form-urlencoded">
         <table border="0" width="100%">
            <tr>
               <td width="10%"><p align="CENTER"><b><font size="1" face="Verdana, Arial, Helvetica">QTY</font></b></td>
               <td width="15%"><b><font size="1" face="Verdana, Arial, Helvetica">ITEM</font></b></td>
               <td width="35%"><b><font size="1" face="Verdana, Arial, Helvetica">DESCRIPTION</font></b></td>
               <td width="15%"><b><font size="1" face="Verdana, Arial, Helvetica">PRICE</font></b></td>
               <td width="25%"><p align="RIGHT"><b><font size="1" face="Verdana, Arial, Helvetica">YOU HAVE</font></b></td>
            </tr>
<?

               $sql2b = "SELECT `money` from `og_cartelinfo` where `id`='$cid'";
      
               @mysql_connect($dbhost,  $dbuser,  $dbpass) or die("Error connecting to database");

               @mysql_select_db($dbname) or die("Error opening database");

               $result2b = @mysql_query($sql2b);
               $myrow2b = @mysql_fetch_array($result2b);

               
         $sqlcs = "SELECT * from `og_cartelrates` where `buy`='1' order by `id`";

        


         $resultcs = @mysql_query($sqlcs);
         $myrowcs = @mysql_fetch_array($resultcs);
         $row_num = @mysql_num_rows($resultcs);
	 echo "NUMBER OF ROWS: ".$row_num;
	 exit();
         do {
?>
            <tr>
               <td width="10%">
                  <center>
                  <p><input type="TEXT" name="item[<? echo $myrowcs[id] ?>]" size="4" style="Font-Family : Verdana, Arial, Helvetica ; Font-Size : 7pt">
                  </center>
               </td>
               <td width="15%"><b><font size="1" face="Verdana, Arial, Helvetica"><? echo $myrowcs[item_name] ?></font></b></td>
               <td width="35%"><b><font size="1" face="Verdana, Arial, Helvetica"><? echo $myrowcs[description] ?></font></b></td>
               <td width="15%"><b><font size="1" face="Verdana, Arial, Helvetica">$<? echo number_format($myrowcs[price]) ?> [<font size="1" face="Verdana, Arial, Helvetica" color="#FFC000"><u><? echo floor(($myrow2b[money] / $myrowcs[price])); ?></u></font>]</font></b></td>
               <?
               $product = $myrowcs[product];
               $sql2 = "SELECT `product` from `og_cartelinfo` where `id`='$cid'";
      
               

               $result2 = @mysql_query($sql2);
               $myrow2 = @mysql_fetch_array($result2);
               ?>
               <td width="25%">
                  <p align="RIGHT"><b><font size="1" face="Verdana, Arial, Helvetica"><? echo number_format($myrow2[$product]) ?></font></b>
               </td>
            </tr>
<?
            } while ($myrowcs = @mysql_fetch_array($resultcs));
?>
<?
if ($case) {
?>
            <tr>
               <td colspan="5"><br>
               <center><b><font size="2" face="Verdana, Arial, Helvetica">Whatcha doin foo? You ain't got enuff cash!</font></b></center>
               </td>
            </tr>
<?
}
?>
            <tr>
               <td colspan="5"><br>
<br>
               <center><b><font size="1" face="Verdana, Arial, Helvetica">You have $<? echo number_format($myrow2b[money]) ?> to spend!</font></b></center><br><br>
               <input type="hidden" name="cid" value="<? echo $cid ?>">
               <center><input type="submit" name="buy items" style="Font-Family : Verdana, Arial, Helvetica ; Font-Size : 7pt"></center>
               </td>
            </tr>
         </table>
         </form>

you should get a "NUMBER OF ROWS: " and next to it a number! please tell me what that number is

Link to comment
Share on other sites

ok then... this means that the query from which you are trying to get the price gives an empty result. try to see if you have info in that table and it is important to create a function to handle the empty result since you do mathematical operations in your script to avoid this kind of problems in the future!

Link to comment
Share on other sites

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.