Jump to content
MakeWebGames

Critical Error's for Mods


johnnyh62

Recommended Posts

When installing some mods such as Mining Mod v2 i get the error below when i visit the mod link.

A critical error has occurred, and page execution has stopped. Below are the details:

PHP Warning: mysql_result(): Unable to jump to row 0 on MySQL result index 15 (2)

Action taken: Line executed: /home/u837966832/public_html/class/class_db_mysql.php:175

Any ideas on how to fix this guys? (McCodesv2)

 

---------

The entire class_db_mysql is below, if i need to make any changes to it do let me know:

 

<?php

if (!defined('MONO_ON'))
{
exit;
}

if (!function_exists('error_critical'))
{
// Umm...
die('<h1>Error</h1>' . 'Error handler not present');
}

if (!extension_loaded('mysql'))
{
// dl doesn't work anymore, crash
error_critical('Database connection failed',
'MySQL extension not present but required', 'N/A',
debug_backtrace(true));
}

class database
{
var $host;
var $user;
var $pass;
var $database;
var $persistent = 0;
var $last_query;
var $result;
var $connection_id;
var $num_queries = 0;
var $start_time;

function configure($host, $user, $pass, $database, $persistent = 0)
{
$this->host = $host;
$this->user = $user;
$this->pass = $pass;
$this->database = $database;
$this->persistent = $persistent;
return 1; //Success.
}

function connect()
{
if (!$this->host)
{
$this->host = "localhost";
}
if (!$this->user)
{
$this->user = "root";
}
if ($this->persistent)
{
$conn = mysql_pconnect($this->host, $this->user, $this->pass);
}
else
{
$conn =
mysql_connect($this->host, $this->user, $this->pass, true);
}
if ($conn === false)
{
error_critical('Database connection failed',
mysql_errno() . ': ' . mysql_error(),
'Attempted to connect to database on ' . $this->host,
debug_backtrace(true));
}
// @overridecharset mysql
$this->connection_id = $conn;
if (!mysql_select_db($this->database, $this->connection_id))
{
error_critical('Database connection failed',
mysql_errno($conn) . ': ' . mysql_error($conn),
'Attempted to select database: ' . $this->database,
debug_backtrace(true));
}
return $this->connection_id;
}

function disconnect()
{
if ($this->connection_id)
{
mysql_close($this->connection_id);
$this->connection_id = 0;
return 1;
}
else
{
return 0;
}
}

function change_db($database)
{
if (!mysql_select_db($database, $this->connection_id))
{
error_critical('Database change failed',
mysql_errno($this->connection_id) . ': '
. mysql_error($this->connection_id),
'Attempted to select database: ' . $database,
debug_backtrace(true));
}
$this->database = $database;
}

function query($query)
{
$this->last_query = $query;
$this->num_queries++;
$this->result = mysql_query($this->last_query, $this->connection_id);
if ($this->result === false)
{
error_critical('Query failed',
mysql_errno($this->connection_id) . ': '
. mysql_error($this->connection_id),
'Attempted to execute query: ' . nl2br($this->last_query),
debug_backtrace(true));
}
return $this->result;
}

function fetch_row($result = 0)
{
if (!$result)
{
$result = $this->result;
}
return mysql_fetch_assoc($result);
}

function num_rows($result = 0)
{
if (!$result)
{
$result = $this->result;
}
return mysql_num_rows($result);
}

function insert_id()
{
return mysql_insert_id($this->connection_id);
}

function fetch_single($result = 0)
{
if (!$result)
{
$result = $this->result;
}
return mysql_result($result, 0, 0);
}

function easy_insert($table, $data)
{
$query = "INSERT INTO `$table` (";
$i = 0;
foreach ($data as $k => $v)
{
$i++;
if ($i > 1)
{
$query .= ", ";
}
$query .= $k;
}
$query .= ") VALUES(";
$i = 0;
foreach ($data as $k => $v)
{
$i++;
if ($i > 1)
{
$query .= ", ";
}
$query .= "'" . $this->escape($v) . "'";
}
$query .= ")";
return $this->query($query);
}

function escape($text)
{
return mysql_real_escape_string($text, $this->connection_id);
}

function affected_rows()
{
return mysql_affected_rows($this->connection_id);
}

function free_result($result)
{
return mysql_free_result($result);
}

}
Edited by johnnyh62
Link to comment
Share on other sites

Post the script where you found the error.

Mine.php is below:

 

<?php
/**
Mining Mod by TheMasterGeneral
Cost: FREE
Use: Allows users to mine up flakes and gems,
which can be used to create items*.


*=Does not include crafting mod.

If you want to use a crafting mod,
I use Sniko's crafting mod along
side this.

SQL:
CREATE TABLE IF NOT EXISTS `Mining` (
 `userid` bigint(11) NOT NULL DEFAULT '1' COMMENT 'Userid',
 `m_level` bigint(11) NOT NULL DEFAULT '1' COMMENT 'Mining Level',
 `mEXP` decimal(11,0) NOT NULL DEFAULT '0' COMMENT 'Mining Exp',
 `mNEXP` decimal(11,0) NOT NULL DEFAULT '100' COMMENT 'Exp needed to level',
 `m_power` bigint(11) NOT NULL DEFAULT '100' COMMENT 'User''s mining power.',
 `m_Mpower` bigint(11) NOT NULL DEFAULT '100' COMMENT 'User''s MAX mining power.',
 `m_mopower` bigint(11) NOT NULL DEFAULT '1' COMMENT 'How much more power can one buy? (In 10 power sets)',
 PRIMARY KEY (`userid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

*/
$macropage = 'mine.php';
require_once('globals.php');
require('mine_globals.php');
echo"    <h3>Dangerous Mines</h3>
   <hr />";
if (!isset($_GET['action']))
{
   $_GET['action'] = '';
}

switch ($_GET['action'])
{
case 'mine':
   mine1();
   break;
case 'mine2':
   mine2();
   break;
case 'mine3':
   mine3();
   break;
case 'buyp':
   minepb();
   break;
case 'mine4':
   mine4();
   break;
case 'mine5':
   mine5();
   break;
case 'mine6':
   mine6();
   break;
default:
   mine_home();
   break;
}
function minepb()
{
global $db, $ir, $c, $userid, $h;
   require('mine_globals.php');
   echo"
   <h3>Dangerous Mines</h3>
   <hr />";
   //
if ($level <= 10)                    //If mining level is 1-10, 100 is the cost to add more power.
{
   $cost = 10;
}
if ($level <= 20 && $level >= 10)    //If mining level is 10-20, 1000 is the cost to add more power.
{
   $cost = 100;
}
if ($level <= 30 && $level >= 20)    //If mining level is 20-30, 5000 is the cost to add more power.
{
   $cost = 1000;
}
if ($level <= 75 && $level >= 30)    //If mining level is 75-30, 2000 is the cost to add more power.
{
   $cost = 2000;
}
if ($level <= 125 && $level >= 75)    //If mining level is 125-75, 5000 is the cost to add more power.
{
   $cost = 5000;
}

   if(!isset($_POST['amount'])) {
print "<form action='mine.php?action=buyp' method='post'>
You can currently buy $mopower sets of 10 mining power. How many do you wish to buy? Each set will cost you $cost IQ. <br><input type='text' name='amount' /><br>

<input type='submit' value='Buy Power (No Prompt, so be sure!)' />
</form>";

} else {
//Secure the ID input.
$_GET['amount'] =
       (isset($_GET['amount']) && is_numeric($_GET['amount']))
               ? abs(intval($_GET['amount'])) : '';

if ($_POST['amount'] > $mopower)
{
echo 'You do not have that many sets available to you. Try again.';
exit;
}
//Fix: Checks the input for negative values
//To prevent users from inputting negative
//values and give themselves labor
//at the cost of losing mining power.
if ($_POST['amount'] < 0)
{
echo 'Stop trying to abuse a game bug. You can be placed in Federal Jail for that.';
exit;
}
if ($_POST['amount'] == 0)
{
echo 'Input must be a number larger than zero.';
exit;
}
if ($laber < $cost)
{
echo "You do not have enough IQ to add {$_POST['amount']} sets of mining power.";
exit;
}
$poweradd = (10*$_POST['amount']);
$subtractlaber = ($cost*$_POST['amount']);

$db->query("UPDATE `userstats`
SET `IQ` = `IQ` - {$subtractlaber}
WHERE `userid` = $userid");

$db->query("UPDATE `Mining`
SET `m_Mpower` = `m_Mpower` + {$poweradd},
`m_mopower` = `m_mopower` - {$_POST['amount']}
WHERE `userid` = $userid");

echo "You have purchased {$_POST['amount']} sets of mining power for $subtractlaber IQ.";
}
}
function mine_home()
{    
global $db, $ir, $c, $userid, $h;
   require('mine_globals.php');
   echo "
   This here be the ye'old mining shack. The mining hole is out back. Feel free to use it if ye got the right gear. There's six mining locations. You've gotta have the minimum level to mine there AND be within the same location. You also gotta make sure you've got the right gear! You will be able to purchase more mining power as well! You can mine up gems, rocks, and of course, <font color=silver>Silver Flakes</font>!<br>
   <hr />

   You have $power / $maxpower mining power.<br>
   <img src='yellowbar.png' width='$mpower' height='10' /><img src='redbar.png' width='$mpower2' height='10' /><br />
   You currently have $miexp % experience.<br>
   <img src='yellowbar.png' width='$miexp' height='10' /><img src='redbar.png' width='$miexp2' height='10' /><br />
   You are level $level in mining.<br>
   <br>
   <br>
   <br>
   [<a href='mine.php?action=mine'>Cornrye - Level 1</a>]<br>
   [<a href='mine.php?action=mine2'>Falconworth - Level 10</a>]<br>
   [<a href='mine.php?action=mine3'>Rome - Level 20</a>]<br>
   [<a href='mine.php?action=mine4'>Timberwolf - Level 40</a>]<br>
   [<a href='mine.php?action=mine5'>Tel Yaga - Level 75</a>]<br>
   [<a href='mine.php?action=mine6'>Dion - Level 125</a>]<br>
   <br>
   <br>
   [<a href='mine.php?action=buyp'>Buy Mining Power</a>]<br>
  ";
}
function mine6()
{
       global $db, $ir, $c, $userid, $h;
   $chance = rand(1,130);
   require('mine_globals.php');
   $query=$db->query("SELECT `inv_itemid` FROM `inventory` where `inv_itemid` = 60 && `inv_userid` = $userid"); //Replace 60 with your Basic Mining Pickaxe item ID.
   $i=mysqli_fetch_array($query);
   if ($place != 9)
   {    
   echo"You are not in Dion!";
   exit;
   }
   //if ($level > 124)
   //{
   //echo "This mine is way too easy for you. Leave it to the kiddies.<br>
   //<a href='mine.php'>Back</a>";
   //exit;
   //}
           if ($level < 125)
   {
       die('Your mining level is too low for this mine.');
   }
   if ($power < 100)
   {
       die(
               "You need 100 mining power to mine here. You have $power.");
   }
   if(!$i['inv_itemid'] == $pick) //Replace 60 with your Basic Mining Pickaxe item ID.
   {
       print "You need a basic pickaxe before you can even consider mining.";
       exit;
   }
   if($laber < 50000)
   {
       print "You need 50000 IQ to mine here! Come back when you have it!";
       exit;
   }
   //Copper Flakes
   if ($chance <= 35)
   {
       $flakes = rand(250, 290);
       $expgain = (2.5*$flakes);
       echo "While mining away, you have uncovered {$flakes} <font color=brown>Copper Flakes</font>!";
       item_add($userid, $copperflakeid, $flakes); //Replace 68 with your <font color=silver>Silver Flakes</font> item ID.
   }
   //Rocks
   if (($chance >= 36) && ($chance <= 50))
   {
       $rocks = rand(60, 80);
       $expgain = (2.25*$rocks);
       echo "While mining away, you have managed to break away {$rocks} rock(s)!";
       item_add($userid, $rocksid, $rocks); //Replace 7 with your Rock item ID.
   }
   //Infirmary
   if (($chance >=51) && ($chance <= 55))
   {
       $hosptime=(int) rand(550,750);
       echo "You collapse a column holding the mineshaft up and caused a cave-in. You are later found under the rubble, barely breathing. You have been escorted to the infirmary for {$hosptime} minutes.";
       $reasonhosp = 'Mining Cave In';
       $db->query("UPDATE users SET `hospital`=$hosptime,`hospreason`='$reasonhosp',`hp`=1 WHERE userid=$userid",$c);
   }
   //Dungeon
   if (($chance >= 56) && ($chance <= 60))
   {
       $jailtime=(int) rand(550,800);
       echo "While mining, a swarm of bugs overcrowd you. In attempt to get rid of them, you rip off your clothing and run into the nearest source of water. A guard sees you and escorts you into the dungeon for {$jailtime} minutes on the account of indecency exposure.";
       $reasonjail = 'Indecency Exposure';
       $db->query("UPDATE users SET `jail` = $jailtime, `jail_reason` = '$reasonjail' WHERE userid=$userid",$c);
   }
   //Failed
   if (($chance >= 61) && ($chance <= 90))
   {
       echo "You gained nothing by mining.";
   }
   //Gem
   if (($chance >= 91) && ($chance <= 93))
   {
       $expgain = (2000);
       echo "While mining away, you chip away a <font color=silver>Medium Sized Emerald</font>. Hold on this, you can use this in crafting!";
       item_add($userid, 149, 1); //Replace 71 with your Small Sapphire item id.
   }
   //Break
   if (($chance >= 94) && ($chance <= 95))
   {
       echo "While mining away, you struck a tough rock and broke your pickaxe. You're going to need to fix that before you can mine again.";
       item_add($userid, $bpick, 1); //Replace 70 with your Broken Basic Pickaxe item ID.
       item_remove($userid, $pick, 1); //Replace 60 with your Basic Mining Pickaxe item ID.
   }
   //Gold Flakes
   if (($chance >= 96) && ($chance <= 110))
   {
       $gflake = rand(120, 200);
       $expgain = (3.5*$gflake);
       echo "While mining away, you have managed to break away {$gflake} <font color=yellow>Gold Flakes</font>!";
       item_add($userid, $goldflakeid, $gflake); //Replace 7 with your Rock item ID.
   }
   //Silver Flakes
   if (($chance >= 111) && ($chance <= 130))
   {
       $sflake = rand(150, 250);
       $expgain = (3*$sflake);
       echo "While mining away, you have managed to break away {$sflake} <font color=silver>Silver Flakes</font>!";
       item_add($userid, $silverflakesid, $sflake); //Replace 7 with your Rock item ID.
   }

   //All done. Run this!            
if ($expgain)
{    
$db->query("UPDATE `Mining` SET `mEXP` = `mEXP` + {$expgain} WHERE `userid` = $userid");
}
   $db->query("UPDATE `Mining` SET `m_power` = `m_power` - 100 WHERE `userid` = $userid");
   die("<hr />
   <a href='mine.php?action=mine6'>Mine Again</a><br />
   <a href='mine.php'>>Back</a>");
}
function mine5()
{
       global $db, $ir, $c, $userid, $h;
   $chance = rand(1,130);
   require('mine_globals.php');
   $query=$db->query("SELECT `inv_itemid` FROM `inventory` where `inv_itemid` = 60 && `inv_userid` = $userid"); //Replace 60 with your Basic Mining Pickaxe item ID.
   $i=mysqli_fetch_array($query);
   if ($place != 6)
   {    
   echo"You are not in Timberwolf!";
   exit;
   }
   if ($level > 124)
   {
   echo "This mine is way too easy for you. Leave it to the kiddies.<br>
   <a href='mine.php'>Back</a>";
   exit;
   }
           if ($level < 75)
   {
       die('Your mining level is too low for this mine.');
   }
   if ($power < 50)
   {
       die(
               "You need 50 mining power to mine here. You have $power.");
   }
   if(!$i['inv_itemid'] == $pick) //Replace 60 with your Basic Mining Pickaxe item ID.
   {
       print "You need a basic pickaxe before you can even consider mining.";
       exit;
   }
   if($laber < 10000)
   {
       print "You need 1000 IQ to mine here! Come back when you have it!";
       exit;
   }
   //Copper Flakes
   if ($chance <= 35)
   {
       $flakes = rand(220, 260);
       $expgain = (2*$flakes);
       echo "While mining away, you have uncovered {$flakes} <font color=brown>Copper Flakes</font>!";
       item_add($userid, $copperflakeid, $flakes); //Replace 68 with your <font color=silver>Silver Flakes</font> item ID.
   }
   //Rocks
   if (($chance >= 36) && ($chance <= 50))
   {
       $rocks = rand(40, 56);
       $expgain = (1.75*$rocks);
       echo "While mining away, you have managed to break away {$rocks} rock(s)!";
       item_add($userid, $rocksid, $rocks); //Replace 7 with your Rock item ID.
   }
   //Infirmary
   if (($chance >=51) && ($chance <= 55))
   {
       $hosptime=(int) rand(300,550);
       echo "You collapse a column holding the mineshaft up and caused a cave-in. You are later found under the rubble, barely breathing. You have been escorted to the infirmary for {$hosptime} minutes.";
       $reasonhosp = 'Mining Cave In';
       $db->query("UPDATE users SET `hospital`=$hosptime,`hospreason`='$reasonhosp',`hp`=1 WHERE userid=$userid",$c);
   }
   //Dungeon
   if (($chance >= 56) && ($chance <= 60))
   {
       $jailtime=(int) rand(330,550);
       echo "While mining, a swarm of bugs overcrowd you. In attempt to get rid of them, you rip off your clothing and run into the nearest source of water. A guard sees you and escorts you into the dungeon for {$jailtime} minutes on the account of indecency exposure.";
       $reasonjail = 'Indecency Exposure';
       $db->query("UPDATE users SET `jail` = $jailtime, `jail_reason` = '$reasonjail' WHERE userid=$userid",$c);
   }
   //Failed
   if (($chance >= 61) && ($chance <= 90))
   {
       echo "You gained nothing by mining.";
   }
   //Gem
   if (($chance >= 91) && ($chance <= 93))
   {
       $expgain = (1500);
       echo "While mining away, you chip away a <font color=silver>Medium Sized Diamond</font>. Hold on this, you can use this in crafting!";
       item_add($userid, 148, 1); //Replace 71 with your Small Sapphire item id.
   }
   //Break
   if (($chance >= 94) && ($chance <= 95))
   {
       echo "While mining away, you struck a tough rock and broke your pickaxe. You're going to need to fix that before you can mine again.";
       item_add($userid, $bpick, 1); //Replace 70 with your Broken Basic Pickaxe item ID.
       item_remove($userid, $pick, 1); //Replace 60 with your Basic Mining Pickaxe item ID.
   }
   //Gold Flakes
   if (($chance >= 96) && ($chance <= 110))
   {
       $gflake = rand(60, 160);
       $expgain = (2.75*$gflake);
       echo "While mining away, you have managed to break away {$gflake} <font color=yellow>Gold Flakes</font>!";
       item_add($userid, $goldflakeid, $gflake); //Replace 7 with your Rock item ID.
   }
   //Silver Flakes
   if (($chance >= 111) && ($chance <= 130))
   {
       $sflake = rand(110, 230);
       $expgain = (2.5*$sflake);
       echo "While mining away, you have managed to break away {$sflake} <font color=silver>Silver Flakes</font>!";
       item_add($userid, $silverflakesid, $sflake); //Replace 7 with your Rock item ID.
   }

   //All done. Run this!            
if ($expgain)
{    
$db->query("UPDATE `Mining` SET `mEXP` = `mEXP` + {$expgain} WHERE `userid` = $userid");
}
   $db->query("UPDATE `Mining` SET `m_power` = `m_power` - 50 WHERE `userid` = $userid");
   die("<hr />
   <a href='mine.php?action=mine5'>Mine Again</a><br />
   <a href='mine.php'>>Back</a>");
}
function mine1()
{
       global $db, $ir, $c, $userid, $h;
   $chance = rand(1,130);
   require('mine_globals.php');
   $query=$db->query("SELECT `inv_itemid` FROM `inventory` where `inv_itemid` = 60 && `inv_userid` = $userid"); //Replace 60 with your Basic Mining Pickaxe item ID.
   $i=mysqli_fetch_array($query);
   if ($place != 1)
   {    
   echo"You are not in Cornrye!";
   exit;
   }
   if ($level > 9)
   {
   echo "This mine is way too easy for you. Leave it to the kiddies.<br>
   <a href='mine.php'>Back</a>";
   exit;
   }
   if ($power < 10)
   {
       die(
               "You need 10 mining power to mine here. You have $power.");
   }
   if(!$i['inv_itemid'] == $pick) //Replace 60 with your Basic Mining Pickaxe item ID.
   {
       print "You need a basic pickaxe before you can even consider mining.";
       exit;
   }
   if($laber < 10)
   {
       print "You need 10 IQ to mine here! Come back when you have it!";
       exit;
   }
   //Copper Flakes
   if ($chance <= 35)
   {
       $flakes = rand(20, 120);
       $expgain = (0.5*$flakes);
       echo "While mining away, you have uncovered {$flakes} <font color=brown>Copper Flakes</font>!";
       item_add($userid, $copperflakeid, $flakes); //Replace 68 with your <font color=silver>Silver Flakes</font> item ID.
   }
   //Rocks
   if (($chance >= 36) && ($chance <= 50))
   {
       $rocks = rand(2, 10);
       $expgain = (0.3*$rocks);
       echo "While mining away, you have managed to break away {$rocks} rock(s)!";
       item_add($userid, $rocksid, $rocks); //Replace 7 with your Rock item ID.
   }
   //Infirmary
   if (($chance >=51) && ($chance <= 55))
   {
       $hosptime=(int) rand(30,120);
       echo "You collapse a column holding the mineshaft up and caused a cave-in. You are later found under the rubble, barely breathing. You have been escorted to the infirmary for {$hosptime} minutes.";
       $reasonhosp = 'Mining Cave In';
       $db->query("UPDATE users SET `hospital`=$hosptime,`hospreason`='$reasonhosp',`hp`=1 WHERE userid=$userid",$c);
   }
   //Dungeon
   if (($chance >= 56) && ($chance <= 60))
   {
       $jailtime=(int) rand(30,180);
       echo "While mining, a swarm of bugs overcrowd you. In attempt to get rid of them, you rip off your clothing and run into the nearest source of water. A guard sees you and escorts you into the dungeon for {$jailtime} minutes on the account of indecency exposure.";
       $reasonjail = 'Indecency Exposure';
       $db->query("UPDATE users SET `jail` = $jailtime, `jail_reason` = '$reasonjail' WHERE userid=$userid",$c);
   }
   //Failed
   if (($chance >= 61) && ($chance <= 90))
   {
       echo "You gained nothing by mining.";
   }
   //Gem
   if (($chance >= 91) && ($chance <= 93))
   {
       $expgain = (35);
       echo "While mining away, you chip away a <font color=blue>Small Sapphire</font>. Hold on this, you can use this in crafting!";
       item_add($userid, $sapphireitem, 1); //Replace 71 with your Small Sapphire item id.
   }
   //Break
   if (($chance >= 94) && ($chance <= 95))
   {
       echo "While mining away, you struck a tough rock and broke your pickaxe. You're going to need to fix that before you can mine again.";
       item_add($userid, $bpick, 1); //Replace 70 with your Broken Basic Pickaxe item ID.
       item_remove($userid, $pick, 1); //Replace 60 with your Basic Mining Pickaxe item ID.
   }
   //Gold Flakes
   if (($chance >= 96) && ($chance <= 110))
   {
       $gflake = rand(5, 50);
       $expgain = (1*$gflake);
       echo "While mining away, you have managed to break away {$gflake} <font color=yellow>Gold Flakes</font>!";
       item_add($userid, $goldflakeid, $gflake); //Replace 7 with your Rock item ID.
   }
   //Silver Flakes
   if (($chance >= 111) && ($chance <= 130))
   {
       $sflake = rand(15, 75);
       $expgain = (0.75*$sflake);
       echo "While mining away, you have managed to break away {$sflake} <font color=silver>Silver Flakes</font>!";
       item_add($userid, $silverflakesid, $sflake); //Replace 7 with your Rock item ID.
   }

   //All done. Run this!            
if ($expgain)
{    
$db->query("UPDATE `Mining` SET `mEXP` = `mEXP` + {$expgain} WHERE `userid` = $userid");
}
   $db->query("UPDATE `Mining` SET `m_power` = `m_power` - 10 WHERE `userid` = $userid");
   die("<hr />
   <a href='mine.php?action=mine'>Mine Again</a><br />
   <a href='mine.php'>>Back</a>");
}
function mine2()
{
       global $db, $ir, $c, $userid, $h;
   $chance = rand(1,130);
   require('mine_globals.php');
   $query=$db->query("SELECT `inv_itemid` FROM `inventory` where `inv_itemid` = 60 && `inv_userid` = $userid"); //Replace 60 with your Basic Mining Pickaxe item ID.
   $i=mysqli_fetch_array($query);
   if ($place != 4)
   {    
   echo"You are not in Falconworth!";
   exit;
   }
   if ($level > 19)
   {
   echo "This mine is way too easy for you. Leave it to the kiddies.<br>
   <a href='mine.php'>Back</a>";
   exit;
   }
       if ($level < 10)
   {
       die('Your mining level is too low for this mine.');
   }
   if ($power < 20)
   {
       die(
               "You need 20 mining power to mine here. You have $power.");
   }
   if(!$i['inv_itemid'] == $pick) //Replace 60 with your Basic Mining Pickaxe item ID.
   {
       print "You need a basic pickaxe before you can even consider mining.";
       exit;
   }
   if($laber < 100)
   {
       print "You need 100 IQ to mine here! Come back when you have it!";
       exit;
   }
   //Copper Flakes
   if ($chance <= 35)
   {
       $flakes = rand(40, 140);
       $expgain = (0.75*$flakes);
       echo "While mining away, you have uncovered {$flakes} <font color=brown>Copper Flakes</font>!";
       item_add($userid, $copperflakeid, $flakes); //Replace 68 with your <font color=silver>Silver Flakes</font> item ID.
   }
   //Rocks
   if (($chance >= 36) && ($chance <= 50))
   {
       $rocks = rand(5, 12);
       $expgain = (0.5*$rocks);
       echo "While mining away, you have managed to break away {$rocks} rock(s)!";
       item_add($userid, $rocksid, $rocks); //Replace 7 with your Rock item ID.
   }
   //Infirmary
   if (($chance >=51) && ($chance <= 55))
   {
       $hosptime=(int) rand(50,150);
       echo "You collapse a column holding the mineshaft up and caused a cave-in. You are later found under the rubble, barely breathing. You have been escorted to the infirmary for {$hosptime} minutes.";
       $reasonhosp = 'Mining Cave In';
       $db->query("UPDATE users SET `hospital`=$hosptime,`hospreason`='$reasonhosp',`hp`=1 WHERE userid=$userid",$c);
   }
   //Dungeon
   if (($chance >= 56) && ($chance <= 60))
   {
       $jailtime=(int) rand(50,200);
       echo "While mining, a swarm of bugs overcrowd you. In attempt to get rid of them, you rip off your clothing and run into the nearest source of water. A guard sees you and escorts you into the dungeon for {$jailtime} minutes on the account of indecency exposure.";
       $reasonjail = 'Indecency Exposure';
       $db->query("UPDATE users SET `jail` = $jailtime, `jail_reason` = '$reasonjail' WHERE userid=$userid",$c);
   }
   //Failed
   if (($chance >= 61) && ($chance <= 90))
   {
       echo "You gained nothing by mining.";
   }
   //Gem
   if (($chance >= 91) && ($chance <= 93))
   {
       $expgain = (150);
       echo "While mining away, you chip away a <font color=silver>Small Diamond</font>. Hold on this, you can use this in crafting!";
       item_add($userid, $diamonditem, 1); //Replace 71 with your Small Sapphire item id.
   }
   //Break
   if (($chance >= 94) && ($chance <= 95))
   {
       echo "While mining away, you struck a tough rock and broke your pickaxe. You're going to need to fix that before you can mine again.";
       item_add($userid, $bpick, 1); //Replace 70 with your Broken Basic Pickaxe item ID.
       item_remove($userid, $pick, 1); //Replace 60 with your Basic Mining Pickaxe item ID.
   }
   //Gold Flakes
   if (($chance >= 96) && ($chance <= 110))
   {
       $gflake = rand(10, 55);
       $expgain = (1.25*$gflake);
       echo "While mining away, you have managed to break away {$gflake} <font color=yellow>Gold Flakes</font>!";
       item_add($userid, $goldflakeid, $gflake); //Replace 7 with your Rock item ID.
   }
   //Silver Flakes
   if (($chance >= 111) && ($chance <= 130))
   {
       $sflake = rand(25, 85);
       $expgain = (1*$sflake);
       echo "While mining away, you have managed to break away {$sflake} <font color=silver>Silver Flakes</font>!";
       item_add($userid, $silverflakesid, $sflake); //Replace 7 with your Rock item ID.
   }

   //All done. Run this!
if ($expgain)
{    
$db->query("UPDATE `Mining` SET `mEXP` = `mEXP` + {$expgain} WHERE `userid` = $userid");
}
   $db->query("UPDATE `Mining` SET `m_power` = `m_power` - 20 WHERE `userid` = $userid");
   die("<hr />
   <a href='mine.php?action=mine2'>Mine Again</a><br />
   <a href='mine.php'>>Back</a>");
}
function mine3()
{
       global $db, $ir, $c, $userid, $h;
   $chance = rand(1,130);
   require('mine_globals.php');
   $query=$db->query("SELECT `inv_itemid` FROM `inventory` where `inv_itemid` = 60 && `inv_userid` = $userid"); //Replace 60 with your Basic Mining Pickaxe item ID.
   $i=mysqli_fetch_array($query);
   if ($place != 5)
   {    
   echo"You are not in Rome!";
   exit;
   }
   if ($level > 39)
   {
   echo "This mine is way too easy for you. Leave it to the kiddies.<br>
   <a href='mine.php'>Back</a>";
   exit;
   }
   if ($level < 20)
   {
       die('Your mining level is too low for this mine.');
   }
   if ($power < 20)
   {
       die(
               "You need 20 mining power to mine here. You have $power.");
   }
   if(!$i['inv_itemid'] == $pick) //Replace 60 with your Basic Mining Pickaxe item ID.
   {
       print "You need a basic pickaxe before you can even consider mining.";
       exit;
   }
   if($laber < 500)
   {
       print "You need 500 IQ to mine here! Come back when you have it!";
       exit;
   }
   //Copper Flakes
   if ($chance <= 35)
   {
       $flakes = rand(60, 160);
       $expgain = (1*$flakes);
       echo "While mining away, you have uncovered {$flakes} <font color=brown>Copper Flakes</font>!";
       item_add($userid, $copperflakeid, $flakes); //Replace 68 with your <font color=silver>Silver Flakes</font> item ID.
   }
   //Rocks
   if (($chance >= 36) && ($chance <= 50))
   {
       $rocks = rand(8, 16);
       $expgain = (0.75*$rocks);
       echo "While mining away, you have managed to break away {$rocks} rock(s)!";
       item_add($userid, $rocksid, $rocks); //Replace 7 with your Rock item ID.
   }
   //Infirmary
   if (($chance >=51) && ($chance <= 55))
   {
       $hosptime=(int) rand(75,175);
       echo "You collapse a column holding the mineshaft up and caused a cave-in. You are later found under the rubble, barely breathing. You have been escorted to the infirmary for {$hosptime} minutes.";
       $reasonhosp = 'Mining Cave In';
       $db->query("UPDATE users SET `hospital`=$hosptime,`hospreason`='$reasonhosp',`hp`=1 WHERE userid=$userid",$c);
   }
   //Dungeon
   if (($chance >= 56) && ($chance <= 60))
   {
       $jailtime=(int) rand(75,225);
       echo "While mining, a swarm of bugs overcrowd you. In attempt to get rid of them, you rip off your clothing and run into the nearest source of water. A guard sees you and escorts you into the dungeon for {$jailtime} minutes on the account of indecency exposure.";
       $reasonjail = 'Indecency Exposure';
       $db->query("UPDATE users SET `jail` = $jailtime, `jail_reason` = '$reasonjail' WHERE userid=$userid",$c);
   }
   //Failed
   if (($chance >= 61) && ($chance <= 90))
   {
       echo "You gained nothing by mining.";
   }
   //Gem
   if (($chance >= 91) && ($chance <= 93))
   {
       $expgain = (500);
       echo "While mining away, you chip away a <font color=green>Emerald</font>. Hold on this, you can use this in crafting!";
       item_add($userid, $emeralditem, 1); //Replace 71 with your Small Sapphire item id.
   }
   //Break
   if (($chance >= 94) && ($chance <= 95))
   {
       echo "While mining away, you struck a tough rock and broke your pickaxe. You're going to need to fix that before you can mine again.";
       item_add($userid, $bpick, 1); //Replace 70 with your Broken Basic Pickaxe item ID.
       item_remove($userid, $pick, 1); //Replace 60 with your Basic Mining Pickaxe item ID.
   }
   //Gold Flakes
   if (($chance >= 96) && ($chance <= 110))
   {
       $gflake = rand(10, 55);
       $expgain = (1.5*$gflake);
       echo "While mining away, you have managed to break away {$gflake} <font color=yellow>Gold Flakes</font>!";
       item_add($userid, $goldflakeid, $gflake); //Replace 7 with your Rock item ID.
   }
   //Silver Flakes
   if (($chance >= 111) && ($chance <= 130))
   {
       $sflake = rand(25, 85);
       $expgain = (1.25*$sflake);
       echo "While mining away, you have managed to break away {$sflake} <font color=silver>Silver Flakes</font>!";
       item_add($userid, $silverflakesid, $sflake); //Replace 7 with your Rock item ID.
   }

   //All done. Run this!            
if ($expgain)
{    
$db->query("UPDATE `Mining` SET `mEXP` = `mEXP` + {$expgain} WHERE `userid` = $userid");
}
   $db->query("UPDATE `Mining` SET `m_power` = `m_power` - 20 WHERE `userid` = $userid");
   die("<hr />
   <a href='mine.php?action=mine3'>Mine Again</a><br />
   <a href='mine.php'>>Back</a>");
}
function mine4()
{
       global $db, $ir, $c, $userid, $h;
   $chance = rand(1,130);
   require('mine_globals.php');
   $query=$db->query("SELECT `inv_itemid` FROM `inventory` where `inv_itemid` = 60 && `inv_userid` = $userid"); //Replace 60 with your Basic Mining Pickaxe item ID.
   $i=mysqli_fetch_array($query);
   if ($place != 6)
   {    
   echo"You are not in Timberwolf!";
   exit;
   }
   if ($level > 74)
   {
   echo "This mine is way too easy for you. Leave it to the kiddies.<br>
   <a href='mine.php'>Back</a>";
   exit;
   }
           if ($level < 40)
   {
       die('Your mining level is too low for this mine.');
   }
   if ($power < 50)
   {
       die(
               "You need 50 mining power to mine here. You have $power.");
   }
   if(!$i['inv_itemid'] == $pick) //Replace 60 with your Basic Mining Pickaxe item ID.
   {
       print "You need a basic pickaxe before you can even consider mining.";
       exit;
   }
   if($laber < 1000)
   {
       print "You need 1000 IQ to mine here! Come back when you have it!";
       exit;
   }
   //Copper Flakes
   if ($chance <= 35)
   {
       $flakes = rand(80, 180);
       $expgain = (1.5*$flakes);
       echo "While mining away, you have uncovered {$flakes} <font color=brown>Copper Flakes</font>!";
       item_add($userid, $copperflakeid, $flakes); //Replace 68 with your <font color=silver>Silver Flakes</font> item ID.
   }
   //Rocks
   if (($chance >= 36) && ($chance <= 50))
   {
       $rocks = rand(20, 36);
       $expgain = (1.25*$rocks);
       echo "While mining away, you have managed to break away {$rocks} rock(s)!";
       item_add($userid, $rocksid, $rocks); //Replace 7 with your Rock item ID.
   }
   //Infirmary
   if (($chance >=51) && ($chance <= 55))
   {
       $hosptime=(int) rand(200,300);
       echo "You collapse a column holding the mineshaft up and caused a cave-in. You are later found under the rubble, barely breathing. You have been escorted to the infirmary for {$hosptime} minutes.";
       $reasonhosp = 'Mining Cave In';
       $db->query("UPDATE users SET `hospital`=$hosptime,`hospreason`='$reasonhosp',`hp`=1 WHERE userid=$userid",$c);
   }
   //Dungeon
   if (($chance >= 56) && ($chance <= 60))
   {
       $jailtime=(int) rand(225,325);
       echo "While mining, a swarm of bugs overcrowd you. In attempt to get rid of them, you rip off your clothing and run into the nearest source of water. A guard sees you and escorts you into the dungeon for {$jailtime} minutes on the account of indecency exposure.";
       $reasonjail = 'Indecency Exposure';
       $db->query("UPDATE users SET `jail` = $jailtime, `jail_reason` = '$reasonjail' WHERE userid=$userid",$c);
   }
   //Failed
   if (($chance >= 61) && ($chance <= 90))
   {
       echo "You gained nothing by mining.";
   }
   //Gem
   if (($chance >= 91) && ($chance <= 93))
   {
       $expgain = (1000);
       echo "While mining away, you chip away a <font color=blue>Medium Sized Sapphire</font>. Hold on this, you can use this in crafting!";
       item_add($userid, 147, 1); //Replace 71 with your Small Sapphire item id.
   }
   //Break
   if (($chance >= 94) && ($chance <= 95))
   {
       echo "While mining away, you struck a tough rock and broke your pickaxe. You're going to need to fix that before you can mine again.";
       item_add($userid, $bpick, 1); //Replace 70 with your Broken Basic Pickaxe item ID.
       item_remove($userid, $pick, 1); //Replace 60 with your Basic Mining Pickaxe item ID.
   }
   //Gold Flakes
   if (($chance >= 96) && ($chance <= 110))
   {
       $gflake = rand(30, 85);
       $expgain = (2.25*$gflake);
       echo "While mining away, you have managed to break away {$gflake} <font color=yellow>Gold Flakes</font>!";
       item_add($userid, $goldflakeid, $gflake); //Replace 7 with your Rock item ID.
   }
   //Silver Flakes
   if (($chance >= 111) && ($chance <= 130))
   {
       $sflake = rand(55, 115);
       $expgain = (2*$sflake);
       echo "While mining away, you have managed to break away {$sflake} <font color=silver>Silver Flakes</font>!";
       item_add($userid, $silverflakesid, $sflake); //Replace 7 with your Rock item ID.
   }

   //All done. Run this!            
if ($expgain)
{    
$db->query("UPDATE `Mining` SET `mEXP` = `mEXP` + {$expgain} WHERE `userid` = $userid");
}
   $db->query("UPDATE `Mining` SET `m_power` = `m_power` - 50 WHERE `userid` = $userid");
   die("<hr />
   <a href='mine.php?action=mine4'>Mine Again</a><br />
   <a href='mine.php'>>Back</a>");
}

 

 

Here's mine_globals.php

 

<?php
require_once('globals.php');
//Call upon database for mining values.
//Item ID's can be altered. They are
//located at the bottom of this file.
$q = $db->query(
                   "SELECT `m_power`
                    FROM `Mining`
                    WHERE `userid` = $userid");
$power = $db->fetch_single($q);
$db->free_result($q);
//
$q = $db->query(
                   "SELECT `m_Mpower`
                    FROM `Mining`
                    WHERE `userid` = $userid");
$maxpower = $db->fetch_single($q);
$db->free_result($q);
//
$q = $db->query(
                   "SELECT `m_mopower`
                    FROM `Mining`
                    WHERE `userid` = $userid");
$mopower = $db->fetch_single($q);
$db->free_result($q);
//
$q = $db->query(
                   "SELECT `m_level`
                    FROM `Mining`
                    WHERE `userid` = $userid");
$level = $db->fetch_single($q);
$db->free_result($q);
//
$q = $db->query(
                   "SELECT `mEXP`
                    FROM `Mining`
                    WHERE `userid` = $userid");
$exp = $db->fetch_single($q);
$db->free_result($q);
//
$q = $db->query(
                   "SELECT `mNEXP`
                    FROM `Mining`
                    WHERE `userid` = $userid");
$nexp = $db->fetch_single($q);
$db->free_result($q);
//
$q = $db->query(
                   "SELECT `IQ`
                    FROM `userstats`
                    WHERE `userid` = $userid");
$laber = $db->fetch_single($q);
$db->free_result($q);
//
$q = $db->query(
                   "SELECT `location`
                    FROM `users`
                    WHERE `userid` = $userid");
$place = $db->fetch_single($q);
$db->free_result($q);
//End DB.
//Status bars.

//Mining power bar
$mpower = min((int) ($power / $maxpower * 100), 100); //Mining Bar Not Used
$mpower2 = 100 - $mpower; //Mining bar used7
//End Mining bar
//Start experience bar
$miexp = min((int) ($exp / $nexp * 100), 100);
$miexp2 = 100 - $miexp;
//End experience bar
//End Status Bars

//Experience gained?
   if ($nexp <= $exp)
   {
       $db->query("UPDATE `Mining` SET `m_level` = `m_level` + 1 WHERE `userid` = $userid");
       $db->query("UPDATE `Mining` SET `mEXP` = 0 WHERE `userid` = $userid");
       $db->query("UPDATE `Mining` SET `mNEXP` = (`mNEXP`*1.25)+50 WHERE `userid` = $userid");
       $db->query("UPDATE `Mining` SET `m_mopower` = `m_mopower` + 1 WHERE `userid` = $userid");

   }
       if ($ir['hospital'] > 0)
   {
       die(
               "Mining is for those who are healthy! You are in the infirmary, thus, you are not healthy.");
   }
   if ($ir['jail'] > 0)
   {
       die(
               "Mining is for the good warrior. You're in the dungeon, so thus, you are not a good warrior.");
   }





   //Edit below for items.
   $pick = 3;                //Mining pickaxe value.
   $silverflakesid = 9;    //Silver flakes ID
   $copperflakeid = 10;    //Copper Flakes ID
   $goldflakeid = 11;        //Gold Flakes ID
   $rocksid = 12;            //Rocks item id
   $sapphireitem = 13;        //Small Sapphire item id
   $bpick = 14;            //Broken pickaxe item id
   $diamonditem = 15;        //Small diamond item id.
   $emeralditem = 16;        //Small emerald item.

Link to comment
Share on other sites

  • 2 years later...
On 8/14/2019 at 10:59 PM, rednspirited said:

im having the same issue when i try running the mine

A critical error has occurred, and this page cannot be displayed. Please try again later.

the code all checks good when i check not sure what ive done wrong.

This was a support request from around 2 years ago.
You're likely missing the SQL, which is why you're encountering that error
Spotted the SQL in OP's post, disregard

Link to comment
Share on other sites

ok here is what i get

1418443377_OperaSnapshot_2019-08-13_184911_battleforobsidianmoon_com.png.459827fbead221f408e9b7c8135d718e.png

		global $db, $ir, $c, $userid, $h;
	$chance = rand(1,130);
	require('mine_globals.php');
	$query=$db->query("SELECT `inv_itemid` FROM `inventory` where `inv_itemid` = 60 && `inv_userid` = $userid"); //Replace 60 with your Basic Mining Pickaxe item ID.
	$i=mysqli_fetch_array($query);
	if ($place != 27)
	{	
	echo"You are not in Southford!";
	exit;
	}

this is the code area 

 

I did notice that I didnt change the 60 went through and did that but still get the same message 

Went and checked the inventory SQL and all is good there 

Link to comment
Share on other sites

Change

$i=mysqli_fetch_array($query);

to

$i = $db->fetch_row($query);

 

mine_globals.php

<?php

require_once 'globals.php';
//Call upon database for mining values.
//Item ID's can be altered. They are
//located at the bottom of this file.
$q = $db->query("SELECT `m_power`, `m_Mpower`, `m_mopower`, `m_level`, `mEXP`, `mNEXP` FROM `Mining` WHERE `userid` = $userid");
$row = $db->fetch_row($q);
$power = $row['m_power'];
$maxpower = $row['m_Mpower'];
$mopower = $row['m_mopower'];
$level = $row['m_level'];
$exp = $row['mEXP'];
$nexp = $row['mNEXP'];
$laber = $ir['IQ'];
$place = $ir['location'];
$db->free_result($q);
//End DB.
//Status bars.

//Mining power bar
$mpower = min((int) ($power / $maxpower * 100), 100); //Mining Bar Not Used
$mpower2 = 100 - $mpower; //Mining bar used7
//End Mining bar
//Start experience bar
$miexp = min((int) ($exp / $nexp * 100), 100);
$miexp2 = 100 - $miexp;
//End experience bar
//End Status Bars

//Experience gained?
if ($nexp <= $exp) {
    $db->query("UPDATE `Mining` SET `m_level` = `m_level` + 1, `mEXP` = 0, `mNEXP` = (`mNEXP`*1.25)+50, `m_mopower` = `m_mopower` + 1 WHERE `userid` = $userid");
}
if ($ir['hospital'] > 0) {
    die('Mining is for those who are healthy! You are in the infirmary, thus, you are not healthy.');
}
if ($ir['jail'] > 0) {
    die("Mining is for the good warrior. You're in the dungeon, so thus, you are not a good warrior.");
}
//Edit below for items.
$pick = 3;                //Mining pickaxe value.
$silverflakesid = 9;    //Silver flakes ID
$copperflakeid = 10;    //Copper Flakes ID
$goldflakeid = 11;        //Gold Flakes ID
$rocksid = 12;            //Rocks item id
$sapphireitem = 13;        //Small Sapphire item id
$bpick = 14;            //Broken pickaxe item id
$diamonditem = 15;        //Small diamond item id.
$emeralditem = 16;        //Small emerald item.

mine.php

<?php
/*
Mining Mod by TheMasterGeneral
Cost: FREE
Use: Allows users to mine up flakes and gems,
which can be used to create items*.


*=Does not include crafting mod.

If you want to use a crafting mod,
I use Sniko's crafting mod along
side this.

SQL:
CREATE TABLE IF NOT EXISTS `Mining` (
`userid` bigint(11) NOT NULL DEFAULT '1' COMMENT 'Userid',
`m_level` bigint(11) NOT NULL DEFAULT '1' COMMENT 'Mining Level',
`mEXP` decimal(11,0) NOT NULL DEFAULT '0' COMMENT 'Mining Exp',
`mNEXP` decimal(11,0) NOT NULL DEFAULT '100' COMMENT 'Exp needed to level',
`m_power` bigint(11) NOT NULL DEFAULT '100' COMMENT 'User''s mining power.',
`m_Mpower` bigint(11) NOT NULL DEFAULT '100' COMMENT 'User''s MAX mining power.',
`m_mopower` bigint(11) NOT NULL DEFAULT '1' COMMENT 'How much more power can one buy? (In 10 power sets)',
PRIMARY KEY (`userid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

*/
$macropage = 'mine.php';
require_once 'globals.php';
require 'mine_globals.php';
echo '<h3>Dangerous Mines</h3><hr />';
if (!isset($_GET['action'])) {
    $_GET['action'] = '';
}

switch ($_GET['action']) {
    case 'mine':
        mine1();
        break;
    case 'mine2':
        mine2();
        break;
    case 'mine3':
        mine3();
        break;
    case 'buyp':
        minepb();
        break;
    case 'mine4':
        mine4();
        break;
    case 'mine5':
        mine5();
        break;
    case 'mine6':
        mine6();
        break;
    default:
        mine_home();
        break;
}
function minepb()
{
    global $db, $ir, $c, $userid, $h;
    require 'mine_globals.php';
    echo '<h3>Dangerous Mines</h3><hr />';

    if ($level <= 10) {                    //If mining level is 1-10, 100 is the cost to add more power.
        $cost = 10;
    }
    if ($level <= 20 && $level >= 10) {    //If mining level is 10-20, 1000 is the cost to add more power.
        $cost = 100;
    }
    if ($level <= 30 && $level >= 20) {    //If mining level is 20-30, 5000 is the cost to add more power.
        $cost = 1000;
    }
    if ($level <= 75 && $level >= 30) {    //If mining level is 75-30, 2000 is the cost to add more power.
        $cost = 2000;
    }
    if ($level <= 125 && $level >= 75) {    //If mining level is 125-75, 5000 is the cost to add more power.
        $cost = 5000;
    }

    if (!isset($_POST['amount'])) {
        echo "<form action='mine.php?action=buyp' method='post'>
        You can currently buy $mopower sets of 10 mining power. How many do you wish to buy? Each set will cost you $cost IQ. <br><input type='text' name='amount' /><br>
        <input type='submit' value='Buy Power (No Prompt, so be sure!)' />
        </form>";
    } else {
        //Secure the ID input.
        $_GET['amount'] = (isset($_GET['amount']) && is_numeric($_GET['amount'])) ? abs(intval($_GET['amount'])) : '';

        if ($_POST['amount'] > $mopower) {
            echo 'You do not have that many sets available to you. Try again.';
            exit;
        }
        //Fix: Checks the input for negative values
        //To prevent users from inputting negative
        //values and give themselves labor
        //at the cost of losing mining power.
        if ($_POST['amount'] < 0) {
            echo 'Stop trying to abuse a game bug. You can be placed in Federal Jail for that.';
            exit;
        }
        if (0 == $_POST['amount']) {
            echo 'Input must be a number larger than zero.';
            exit;
        }
        if ($laber < $cost) {
            echo "You do not have enough IQ to add {$_POST['amount']} sets of mining power.";
            exit;
        }
        $poweradd = (10 * $_POST['amount']);
        $subtractlaber = ($cost * $_POST['amount']);

        $db->query("UPDATE `userstats` SET `IQ` = `IQ` - {$subtractlaber} WHERE `userid` = $userid");
        $db->query("UPDATE `Mining` SET `m_Mpower` = `m_Mpower` + {$poweradd}, `m_mopower` = `m_mopower` - {$_POST['amount']} WHERE `userid` = $userid");
        echo "You have purchased {$_POST['amount']} sets of mining power for $subtractlaber IQ.";
    }
}
function mine_home()
{
    global $db, $ir, $c, $userid, $h;
    require 'mine_globals.php';
    echo "
This here be the ye'old mining shack. The mining hole is out back. Feel free to use it if ye got the right gear. There's six mining locations. You've gotta have the minimum level to mine there AND be within the same location. You also gotta make sure you've got the right gear! You will be able to purchase more mining power as well! You can mine up gems, rocks, and of course, <font color=silver>Silver Flakes</font>!<br>
<hr />

You have $power / $maxpower mining power.<br>
<img src='yellowbar.png' width='$mpower' height='10' /><img src='redbar.png' width='$mpower2' height='10' /><br />
You currently have $miexp % experience.<br>
<img src='yellowbar.png' width='$miexp' height='10' /><img src='redbar.png' width='$miexp2' height='10' /><br />
You are level $level in mining.<br>
<br>
<br>
<br>
[<a href='mine.php?action=mine'>Cornrye - Level 1</a>]<br>
[<a href='mine.php?action=mine2'>Falconworth - Level 10</a>]<br>
[<a href='mine.php?action=mine3'>Rome - Level 20</a>]<br>
[<a href='mine.php?action=mine4'>Timberwolf - Level 40</a>]<br>
[<a href='mine.php?action=mine5'>Tel Yaga - Level 75</a>]<br>
[<a href='mine.php?action=mine6'>Dion - Level 125</a>]<br>
<br>
<br>
[<a href='mine.php?action=buyp'>Buy Mining Power</a>]<br>
";
}
function mine6()
{
    global $db, $ir, $c, $userid, $h;
    $chance = rand(1, 130);
    require 'mine_globals.php';
    $query = $db->query('SELECT `inv_itemid` FROM `inventory` WHERE `inv_itemid` = '.$pick." && `inv_userid` = $userid");
    $i = $db->fetch_row($query);
    if (9 != $place) {
        echo 'You are not in Dion!';
        exit;
    }
    //if ($level > 124)
    //{
    //echo "This mine is way too easy for you. Leave it to the kiddies.<br>
    //<a href='mine.php'>Back</a>";
    //exit;
    //}
    if ($level < 125) {
        die('Your mining level is too low for this mine.');
    }
    if ($power < 100) {
        die("You need 100 mining power to mine here. You have $power.");
    }
    if (!$i['inv_itemid'] == $pick) {
        echo 'You need a basic pickaxe before you can even consider mining.';
        exit;
    }
    if ($laber < 50000) {
        echo 'You need 50000 IQ to mine here! Come back when you have it!';
        exit;
    }
    //Copper Flakes
    if ($chance <= 35) {
        $flakes = rand(250, 290);
        $expgain = (2.5 * $flakes);
        echo "While mining away, you have uncovered {$flakes} <font color=brown>Copper Flakes</font>!";
        item_add($userid, $copperflakeid, $flakes);
    }
    //Rocks
    if (($chance >= 36) && ($chance <= 50)) {
        $rocks = rand(60, 80);
        $expgain = (2.25 * $rocks);
        echo "While mining away, you have managed to break away {$rocks} rock(s)!";
        item_add($userid, $rocksid, $rocks);
    }
    //Infirmary
    if (($chance >= 51) && ($chance <= 55)) {
        $hosptime = (int) rand(550, 750);
        echo "You collapse a column holding the mineshaft up and caused a cave-in. You are later found under the rubble, barely breathing. You have been escorted to the infirmary for {$hosptime} minutes.";
        $reasonhosp = 'Mining Cave In';
        $db->query("UPDATE users SET `hospital`=$hosptime,`hospreason`='$reasonhosp',`hp`=1 WHERE userid=$userid", $c);
    }
    //Dungeon
    if (($chance >= 56) && ($chance <= 60)) {
        $jailtime = (int) rand(550, 800);
        echo "While mining, a swarm of bugs overcrowd you. In attempt to get rid of them, you rip off your clothing and run into the nearest source of water. A guard sees you and escorts you into the dungeon for {$jailtime} minutes on the account of indecency exposure.";
        $reasonjail = 'Indecency Exposure';
        $db->query("UPDATE users SET `jail` = $jailtime, `jail_reason` = '$reasonjail' WHERE userid=$userid", $c);
    }
    //Failed
    if (($chance >= 61) && ($chance <= 90)) {
        echo 'You gained nothing by mining.';
    }
    //Gem
    if (($chance >= 91) && ($chance <= 93)) {
        $expgain = (2000);
        echo 'While mining away, you chip away a <font color=silver>Medium Sized Emerald</font>. Hold on this, you can use this in crafting!';
        item_add($userid, 149, 1); //Replace 71 with your Small Sapphire item id.
    }
    //Break
    if (($chance >= 94) && ($chance <= 95)) {
        echo "While mining away, you struck a tough rock and broke your pickaxe. You're going to need to fix that before you can mine again.";
        item_add($userid, $bpick, 1);
        item_remove($userid, $pick, 1);
    }
    //Gold Flakes
    if (($chance >= 96) && ($chance <= 110)) {
        $gflake = rand(120, 200);
        $expgain = (3.5 * $gflake);
        echo "While mining away, you have managed to break away {$gflake} <font color=yellow>Gold Flakes</font>!";
        item_add($userid, $goldflakeid, $gflake);
    }
    //Silver Flakes
    if (($chance >= 111) && ($chance <= 130)) {
        $sflake = rand(150, 250);
        $expgain = (3 * $sflake);
        echo "While mining away, you have managed to break away {$sflake} <font color=silver>Silver Flakes</font>!";
        item_add($userid, $silverflakesid, $sflake);
    }

    //All done. Run this!
    if ($expgain) {
        $db->query("UPDATE `Mining` SET `mEXP` = `mEXP` + {$expgain} WHERE `userid` = $userid");
    }
    $db->query("UPDATE `Mining` SET `m_power` = `m_power` - 100 WHERE `userid` = $userid");
    die("<hr />
    <a href='mine.php?action=mine6'>Mine Again</a><br />
    <a href='mine.php'>>Back</a>");
}
function mine5()
{
    global $db, $ir, $c, $userid, $h;
    $chance = rand(1, 130);
    require 'mine_globals.php';
    $query = $db->query('SELECT `inv_itemid` FROM `inventory` WHERE `inv_itemid` = '.$pick." && `inv_userid` = $userid");
    $i = $db->fetch_row($query);
    if (6 != $place) {
        echo'You are not in Timberwolf!';
        exit;
    }
    if ($level > 124) {
        echo "This mine is way too easy for you. Leave it to the kiddies.<br>
        <a href='mine.php'>Back</a>";
        exit;
    }
    if ($level < 75) {
        die('Your mining level is too low for this mine.');
    }
    if ($power < 50) {
        die("You need 50 mining power to mine here. You have $power.");
    }
    if (!$i['inv_itemid'] == $pick) {
        echo 'You need a basic pickaxe before you can even consider mining.';
        exit;
    }
    if ($laber < 10000) {
        echo 'You need 1000 IQ to mine here! Come back when you have it!';
        exit;
    }
    //Copper Flakes
    if ($chance <= 35) {
        $flakes = rand(220, 260);
        $expgain = (2 * $flakes);
        echo "While mining away, you have uncovered {$flakes} <font color=brown>Copper Flakes</font>!";
        item_add($userid, $copperflakeid, $flakes);
    }
    //Rocks
    if (($chance >= 36) && ($chance <= 50)) {
        $rocks = rand(40, 56);
        $expgain = (1.75 * $rocks);
        echo "While mining away, you have managed to break away {$rocks} rock(s)!";
        item_add($userid, $rocksid, $rocks);
    }
    //Infirmary
    if (($chance >= 51) && ($chance <= 55)) {
        $hosptime = (int) rand(300, 550);
        echo "You collapse a column holding the mineshaft up and caused a cave-in. You are later found under the rubble, barely breathing. You have been escorted to the infirmary for {$hosptime} minutes.";
        $reasonhosp = 'Mining Cave In';
        $db->query("UPDATE users SET `hospital`=$hosptime,`hospreason`='$reasonhosp',`hp`=1 WHERE userid=$userid", $c);
    }
    //Dungeon
    if (($chance >= 56) && ($chance <= 60)) {
        $jailtime = (int) rand(330, 550);
        echo "While mining, a swarm of bugs overcrowd you. In attempt to get rid of them, you rip off your clothing and run into the nearest source of water. A guard sees you and escorts you into the dungeon for {$jailtime} minutes on the account of indecency exposure.";
        $reasonjail = 'Indecency Exposure';
        $db->query("UPDATE users SET `jail` = $jailtime, `jail_reason` = '$reasonjail' WHERE userid=$userid", $c);
    }
    //Failed
    if (($chance >= 61) && ($chance <= 90)) {
        echo 'You gained nothing by mining.';
    }
    //Gem
    if (($chance >= 91) && ($chance <= 93)) {
        $expgain = (1500);
        echo 'While mining away, you chip away a <font color=silver>Medium Sized Diamond</font>. Hold on this, you can use this in crafting!';
        item_add($userid, 148, 1); //Replace 71 with your Small Sapphire item id.
    }
    //Break
    if (($chance >= 94) && ($chance <= 95)) {
        echo "While mining away, you struck a tough rock and broke your pickaxe. You're going to need to fix that before you can mine again.";
        item_add($userid, $bpick, 1);
        item_remove($userid, $pick, 1);
    }
    //Gold Flakes
    if (($chance >= 96) && ($chance <= 110)) {
        $gflake = rand(60, 160);
        $expgain = (2.75 * $gflake);
        echo "While mining away, you have managed to break away {$gflake} <font color=yellow>Gold Flakes</font>!";
        item_add($userid, $goldflakeid, $gflake);
    }
    //Silver Flakes
    if (($chance >= 111) && ($chance <= 130)) {
        $sflake = rand(110, 230);
        $expgain = (2.5 * $sflake);
        echo "While mining away, you have managed to break away {$sflake} <font color=silver>Silver Flakes</font>!";
        item_add($userid, $silverflakesid, $sflake);
    }

    //All done. Run this!
    if ($expgain) {
        $db->query("UPDATE `Mining` SET `mEXP` = `mEXP` + {$expgain} WHERE `userid` = $userid");
    }
    $db->query("UPDATE `Mining` SET `m_power` = `m_power` - 50 WHERE `userid` = $userid");
    die("<hr />
    <a href='mine.php?action=mine5'>Mine Again</a><br />
    <a href='mine.php'>>Back</a>");
}
function mine1()
{
    global $db, $ir, $c, $userid, $h;
    $chance = rand(1, 130);
    require 'mine_globals.php';
    $query = $db->query('SELECT `inv_itemid` FROM `inventory` WHERE `inv_itemid` = '.$pick." && `inv_userid` = $userid");
    $i = $db->fetch_row($query);
    if (1 != $place) {
        echo'You are not in Cornrye!';
        exit;
    }
    if ($level > 9) {
        echo "This mine is way too easy for you. Leave it to the kiddies.<br>
        <a href='mine.php'>Back</a>";
        exit;
    }
    if ($power < 10) {
        die("You need 10 mining power to mine here. You have $power.");
    }
    if (!$i['inv_itemid'] == $pick) {
        echo 'You need a basic pickaxe before you can even consider mining.';
        exit;
    }
    if ($laber < 10) {
        echo 'You need 10 IQ to mine here! Come back when you have it!';
        exit;
    }
    //Copper Flakes
    if ($chance <= 35) {
        $flakes = rand(20, 120);
        $expgain = (0.5 * $flakes);
        echo "While mining away, you have uncovered {$flakes} <font color=brown>Copper Flakes</font>!";
        item_add($userid, $copperflakeid, $flakes);
    }
    //Rocks
    if (($chance >= 36) && ($chance <= 50)) {
        $rocks = rand(2, 10);
        $expgain = (0.3 * $rocks);
        echo "While mining away, you have managed to break away {$rocks} rock(s)!";
        item_add($userid, $rocksid, $rocks);
    }
    //Infirmary
    if (($chance >= 51) && ($chance <= 55)) {
        $hosptime = (int) rand(30, 120);
        echo "You collapse a column holding the mineshaft up and caused a cave-in. You are later found under the rubble, barely breathing. You have been escorted to the infirmary for {$hosptime} minutes.";
        $reasonhosp = 'Mining Cave In';
        $db->query("UPDATE users SET `hospital`=$hosptime,`hospreason`='$reasonhosp',`hp`=1 WHERE userid=$userid", $c);
    }
    //Dungeon
    if (($chance >= 56) && ($chance <= 60)) {
        $jailtime = (int) rand(30, 180);
        echo "While mining, a swarm of bugs overcrowd you. In attempt to get rid of them, you rip off your clothing and run into the nearest source of water. A guard sees you and escorts you into the dungeon for {$jailtime} minutes on the account of indecency exposure.";
        $reasonjail = 'Indecency Exposure';
        $db->query("UPDATE users SET `jail` = $jailtime, `jail_reason` = '$reasonjail' WHERE userid=$userid", $c);
    }
    //Failed
    if (($chance >= 61) && ($chance <= 90)) {
        echo 'You gained nothing by mining.';
    }
    //Gem
    if (($chance >= 91) && ($chance <= 93)) {
        $expgain = (35);
        echo 'While mining away, you chip away a <font color=blue>Small Sapphire</font>. Hold on this, you can use this in crafting!';
        item_add($userid, $sapphireitem, 1); //Replace 71 with your Small Sapphire item id.
    }
    //Break
    if (($chance >= 94) && ($chance <= 95)) {
        echo "While mining away, you struck a tough rock and broke your pickaxe. You're going to need to fix that before you can mine again.";
        item_add($userid, $bpick, 1);
        item_remove($userid, $pick, 1);
    }
    //Gold Flakes
    if (($chance >= 96) && ($chance <= 110)) {
        $gflake = rand(5, 50);
        $expgain = (1 * $gflake);
        echo "While mining away, you have managed to break away {$gflake} <font color=yellow>Gold Flakes</font>!";
        item_add($userid, $goldflakeid, $gflake);
    }
    //Silver Flakes
    if (($chance >= 111) && ($chance <= 130)) {
        $sflake = rand(15, 75);
        $expgain = (0.75 * $sflake);
        echo "While mining away, you have managed to break away {$sflake} <font color=silver>Silver Flakes</font>!";
        item_add($userid, $silverflakesid, $sflake);
    }

    //All done. Run this!
    if ($expgain) {
        $db->query("UPDATE `Mining` SET `mEXP` = `mEXP` + {$expgain} WHERE `userid` = $userid");
    }
    $db->query("UPDATE `Mining` SET `m_power` = `m_power` - 10 WHERE `userid` = $userid");
    die("<hr />
    <a href='mine.php?action=mine'>Mine Again</a><br />
    <a href='mine.php'>>Back</a>");
}
function mine2()
{
    global $db, $ir, $c, $userid, $h;
    $chance = rand(1, 130);
    require 'mine_globals.php';
    $query = $db->query('SELECT `inv_itemid` FROM `inventory` WHERE `inv_itemid` = '.$pick." && `inv_userid` = $userid");
    $i = $db->fetch_row($query);
    if (4 != $place) {
        echo'You are not in Falconworth!';
        exit;
    }
    if ($level > 19) {
        echo "This mine is way too easy for you. Leave it to the kiddies.<br>
        <a href='mine.php'>Back</a>";
        exit;
    }
    if ($level < 10) {
        die('Your mining level is too low for this mine.');
    }
    if ($power < 20) {
        die("You need 20 mining power to mine here. You have $power.");
    }
    if (!$i['inv_itemid'] == $pick) {
        echo 'You need a basic pickaxe before you can even consider mining.';
        exit;
    }
    if ($laber < 100) {
        echo 'You need 100 IQ to mine here! Come back when you have it!';
        exit;
    }
    //Copper Flakes
    if ($chance <= 35) {
        $flakes = rand(40, 140);
        $expgain = (0.75 * $flakes);
        echo "While mining away, you have uncovered {$flakes} <font color=brown>Copper Flakes</font>!";
        item_add($userid, $copperflakeid, $flakes);
    }
    //Rocks
    if (($chance >= 36) && ($chance <= 50)) {
        $rocks = rand(5, 12);
        $expgain = (0.5 * $rocks);
        echo "While mining away, you have managed to break away {$rocks} rock(s)!";
        item_add($userid, $rocksid, $rocks);
    }
    //Infirmary
    if (($chance >= 51) && ($chance <= 55)) {
        $hosptime = (int) rand(50, 150);
        echo "You collapse a column holding the mineshaft up and caused a cave-in. You are later found under the rubble, barely breathing. You have been escorted to the infirmary for {$hosptime} minutes.";
        $reasonhosp = 'Mining Cave In';
        $db->query("UPDATE users SET `hospital`=$hosptime,`hospreason`='$reasonhosp',`hp`=1 WHERE userid=$userid", $c);
    }
    //Dungeon
    if (($chance >= 56) && ($chance <= 60)) {
        $jailtime = (int) rand(50, 200);
        echo "While mining, a swarm of bugs overcrowd you. In attempt to get rid of them, you rip off your clothing and run into the nearest source of water. A guard sees you and escorts you into the dungeon for {$jailtime} minutes on the account of indecency exposure.";
        $reasonjail = 'Indecency Exposure';
        $db->query("UPDATE users SET `jail` = $jailtime, `jail_reason` = '$reasonjail' WHERE userid=$userid", $c);
    }
    //Failed
    if (($chance >= 61) && ($chance <= 90)) {
        echo 'You gained nothing by mining.';
    }
    //Gem
    if (($chance >= 91) && ($chance <= 93)) {
        $expgain = (150);
        echo 'While mining away, you chip away a <font color=silver>Small Diamond</font>. Hold on this, you can use this in crafting!';
        item_add($userid, $diamonditem, 1); //Replace 71 with your Small Sapphire item id.
    }
    //Break
    if (($chance >= 94) && ($chance <= 95)) {
        echo "While mining away, you struck a tough rock and broke your pickaxe. You're going to need to fix that before you can mine again.";
        item_add($userid, $bpick, 1);
        item_remove($userid, $pick, 1);
    }
    //Gold Flakes
    if (($chance >= 96) && ($chance <= 110)) {
        $gflake = rand(10, 55);
        $expgain = (1.25 * $gflake);
        echo "While mining away, you have managed to break away {$gflake} <font color=yellow>Gold Flakes</font>!";
        item_add($userid, $goldflakeid, $gflake);
    }
    //Silver Flakes
    if (($chance >= 111) && ($chance <= 130)) {
        $sflake = rand(25, 85);
        $expgain = (1 * $sflake);
        echo "While mining away, you have managed to break away {$sflake} <font color=silver>Silver Flakes</font>!";
        item_add($userid, $silverflakesid, $sflake);
    }

    //All done. Run this!
    if ($expgain) {
        $db->query("UPDATE `Mining` SET `mEXP` = `mEXP` + {$expgain} WHERE `userid` = $userid");
    }
    $db->query("UPDATE `Mining` SET `m_power` = `m_power` - 20 WHERE `userid` = $userid");
    die("<hr />
    <a href='mine.php?action=mine2'>Mine Again</a><br />
    <a href='mine.php'>>Back</a>");
}
function mine3()
{
    global $db, $ir, $c, $userid, $h;
    $chance = rand(1, 130);
    require 'mine_globals.php';
    $query = $db->query('SELECT `inv_itemid` FROM `inventory` WHERE `inv_itemid` = '.$pick." && `inv_userid` = $userid");
    $i = $db->fetch_row($query);
    if (5 != $place) {
        echo'You are not in Rome!';
        exit;
    }
    if ($level > 39) {
        echo "This mine is way too easy for you. Leave it to the kiddies.<br>
        <a href='mine.php'>Back</a>";
        exit;
    }
    if ($level < 20) {
        die('Your mining level is too low for this mine.');
    }
    if ($power < 20) {
        die("You need 20 mining power to mine here. You have $power.");
    }
    if (!$i['inv_itemid'] == $pick) {
        echo 'You need a basic pickaxe before you can even consider mining.';
        exit;
    }
    if ($laber < 500) {
        echo 'You need 500 IQ to mine here! Come back when you have it!';
        exit;
    }
    //Copper Flakes
    if ($chance <= 35) {
        $flakes = rand(60, 160);
        $expgain = (1 * $flakes);
        echo "While mining away, you have uncovered {$flakes} <font color=brown>Copper Flakes</font>!";
        item_add($userid, $copperflakeid, $flakes);
    }
    //Rocks
    if (($chance >= 36) && ($chance <= 50)) {
        $rocks = rand(8, 16);
        $expgain = (0.75 * $rocks);
        echo "While mining away, you have managed to break away {$rocks} rock(s)!";
        item_add($userid, $rocksid, $rocks);
    }
    //Infirmary
    if (($chance >= 51) && ($chance <= 55)) {
        $hosptime = (int) rand(75, 175);
        echo "You collapse a column holding the mineshaft up and caused a cave-in. You are later found under the rubble, barely breathing. You have been escorted to the infirmary for {$hosptime} minutes.";
        $reasonhosp = 'Mining Cave In';
        $db->query("UPDATE users SET `hospital`=$hosptime,`hospreason`='$reasonhosp',`hp`=1 WHERE userid=$userid", $c);
    }
    //Dungeon
    if (($chance >= 56) && ($chance <= 60)) {
        $jailtime = (int) rand(75, 225);
        echo "While mining, a swarm of bugs overcrowd you. In attempt to get rid of them, you rip off your clothing and run into the nearest source of water. A guard sees you and escorts you into the dungeon for {$jailtime} minutes on the account of indecency exposure.";
        $reasonjail = 'Indecency Exposure';
        $db->query("UPDATE users SET `jail` = $jailtime, `jail_reason` = '$reasonjail' WHERE userid=$userid", $c);
    }
    //Failed
    if (($chance >= 61) && ($chance <= 90)) {
        echo 'You gained nothing by mining.';
    }
    //Gem
    if (($chance >= 91) && ($chance <= 93)) {
        $expgain = (500);
        echo 'While mining away, you chip away a <font color=green>Emerald</font>. Hold on this, you can use this in crafting!';
        item_add($userid, $emeralditem, 1); //Replace 71 with your Small Sapphire item id.
    }
    //Break
    if (($chance >= 94) && ($chance <= 95)) {
        echo "While mining away, you struck a tough rock and broke your pickaxe. You're going to need to fix that before you can mine again.";
        item_add($userid, $bpick, 1);
        item_remove($userid, $pick, 1);
    }
    //Gold Flakes
    if (($chance >= 96) && ($chance <= 110)) {
        $gflake = rand(10, 55);
        $expgain = (1.5 * $gflake);
        echo "While mining away, you have managed to break away {$gflake} <font color=yellow>Gold Flakes</font>!";
        item_add($userid, $goldflakeid, $gflake);
    }
    //Silver Flakes
    if (($chance >= 111) && ($chance <= 130)) {
        $sflake = rand(25, 85);
        $expgain = (1.25 * $sflake);
        echo "While mining away, you have managed to break away {$sflake} <font color=silver>Silver Flakes</font>!";
        item_add($userid, $silverflakesid, $sflake);
    }

    //All done. Run this!
    if ($expgain) {
        $db->query("UPDATE `Mining` SET `mEXP` = `mEXP` + {$expgain} WHERE `userid` = $userid");
    }
    $db->query("UPDATE `Mining` SET `m_power` = `m_power` - 20 WHERE `userid` = $userid");
    die("<hr />
    <a href='mine.php?action=mine3'>Mine Again</a><br />
    <a href='mine.php'>>Back</a>");
}
function mine4()
{
    global $db, $ir, $c, $userid, $h;
    $chance = rand(1, 130);
    require 'mine_globals.php';
    $query = $db->query('SELECT `inv_itemid` FROM `inventory` WHERE `inv_itemid` = '.$pick." && `inv_userid` = $userid");
    $i = $db->fetch_row($query);
    if (6 != $place) {
        echo'You are not in Timberwolf!';
        exit;
    }
    if ($level > 74) {
        echo "This mine is way too easy for you. Leave it to the kiddies.<br>
        <a href='mine.php'>Back</a>";
        exit;
    }
    if ($level < 40) {
        die('Your mining level is too low for this mine.');
    }
    if ($power < 50) {
        die("You need 50 mining power to mine here. You have $power.");
    }
    if (!$i['inv_itemid'] == $pick) {
        echo 'You need a basic pickaxe before you can even consider mining.';
        exit;
    }
    if ($laber < 1000) {
        echo 'You need 1000 IQ to mine here! Come back when you have it!';
        exit;
    }
    //Copper Flakes
    if ($chance <= 35) {
        $flakes = rand(80, 180);
        $expgain = (1.5 * $flakes);
        echo "While mining away, you have uncovered {$flakes} <font color=brown>Copper Flakes</font>!";
        item_add($userid, $copperflakeid, $flakes);
    }
    //Rocks
    if (($chance >= 36) && ($chance <= 50)) {
        $rocks = rand(20, 36);
        $expgain = (1.25 * $rocks);
        echo "While mining away, you have managed to break away {$rocks} rock(s)!";
        item_add($userid, $rocksid, $rocks);
    }
    //Infirmary
    if (($chance >= 51) && ($chance <= 55)) {
        $hosptime = (int) rand(200, 300);
        echo "You collapse a column holding the mineshaft up and caused a cave-in. You are later found under the rubble, barely breathing. You have been escorted to the infirmary for {$hosptime} minutes.";
        $reasonhosp = 'Mining Cave In';
        $db->query("UPDATE users SET `hospital`=$hosptime,`hospreason`='$reasonhosp',`hp`=1 WHERE userid=$userid", $c);
    }
    //Dungeon
    if (($chance >= 56) && ($chance <= 60)) {
        $jailtime = (int) rand(225, 325);
        echo "While mining, a swarm of bugs overcrowd you. In attempt to get rid of them, you rip off your clothing and run into the nearest source of water. A guard sees you and escorts you into the dungeon for {$jailtime} minutes on the account of indecency exposure.";
        $reasonjail = 'Indecency Exposure';
        $db->query("UPDATE users SET `jail` = $jailtime, `jail_reason` = '$reasonjail' WHERE userid=$userid", $c);
    }
    //Failed
    if (($chance >= 61) && ($chance <= 90)) {
        echo 'You gained nothing by mining.';
    }
    //Gem
    if (($chance >= 91) && ($chance <= 93)) {
        $expgain = (1000);
        echo 'While mining away, you chip away a <font color=blue>Medium Sized Sapphire</font>. Hold on this, you can use this in crafting!';
        item_add($userid, 147, 1); //Replace 71 with your Small Sapphire item id.
    }
    //Break
    if (($chance >= 94) && ($chance <= 95)) {
        echo "While mining away, you struck a tough rock and broke your pickaxe. You're going to need to fix that before you can mine again.";
        item_add($userid, $bpick, 1);
        item_remove($userid, $pick, 1);
    }
    //Gold Flakes
    if (($chance >= 96) && ($chance <= 110)) {
        $gflake = rand(30, 85);
        $expgain = (2.25 * $gflake);
        echo "While mining away, you have managed to break away {$gflake} <font color=yellow>Gold Flakes</font>!";
        item_add($userid, $goldflakeid, $gflake);
    }
    //Silver Flakes
    if (($chance >= 111) && ($chance <= 130)) {
        $sflake = rand(55, 115);
        $expgain = (2 * $sflake);
        echo "While mining away, you have managed to break away {$sflake} <font color=silver>Silver Flakes</font>!";
        item_add($userid, $silverflakesid, $sflake);
    }

    //All done. Run this!
    if ($expgain) {
        $db->query("UPDATE `Mining` SET `mEXP` = `mEXP` + {$expgain} WHERE `userid` = $userid");
    }
    $db->query("UPDATE `Mining` SET `m_power` = `m_power` - 50 WHERE `userid` = $userid");
    die("<hr />
    <a href='mine.php?action=mine4'>Mine Again</a><br />
    <a href='mine.php'>>Back</a>");
}

 

  • Thanks 1
Link to comment
Share on other sites

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.   Paste as plain text instead

  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...