skooda Posted May 19, 2012 Posted May 19, 2012 Hey I get this error internal error with crystal dealer mod Heres the error Here are some suggestions: Reload this webpage later. HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request. heres the file <?php /*---------------------------------------------------------- -- Crystal Dealer -- Please DO NOT alter this section -- This page has been developed by David Armstead (Maniak) -- Contact me @ <a href="mailto:[email protected]">[email protected]</a> ----------------------------------------------------------*/ include_once (DIRNAME(__FILE__) .'/globals.php'); $_GET['action'] = isset($_GET['action']) && ctype_alpha($_GET['action']) ? trim($_GET['action']) : 'index'; switch($_GET['action']) { case 'add': add(); break; case 'Buy': Buy(); break; default: index(); break; } if (!in_array($_GET['action'], array('index', 'add'))) { echo('Invalid Command!'); exit($h->endpage()); } function index() { global $db, $ir, $h; $q=$db->query("SELECT * FROM `crydeal`"); echo "<h3><span class="highlight">Crystal</span> <span class="highlight">Dealer</span></h3>"; if($ir['user_level'] == 2) { echo "<p align='left'><a href="http://?action=add" target="_blank">Add crystals to the <span class="highlight">dealer</span></a></p>"; } echo "<p align='left'>Welcome to the <span class="highlight">crystal</span> <span class="highlight">Dealer</span>. Here you can buy a set amount of crystals from the game for a set price.</p> <table width='50%' class='table'><tr> <td class='h' width='40%'>Number of Crystals</td> <td class='h' width='40%'>Cost</td> <td class='h' width='10%'></td> </tr>"; if(!$db->num_rows($q)) { echo "<tr><td colspan='3' align = 'center'>No crystals for sale here!</td></tr>"; } else { while ($r=$db->fetch_row($q)) { echo "<tr> <td width='40%'>".number_format($r['crystals'])."</td> <td width='40%'>$".number_format($r['price'])."</td> <td width='10%'><a href='<span class="highlight">dealer</span>.php?action=Buy&id=".$r['id']."'>[buy]</td> </tr>"; } } echo "</table>"; } function add() { global $db, $ir, $h; if(isset($_POST['submit'])) { if(!isset($_POST['crystals'])) { echo "Amount of crystals cannot be empty!"; exit($h->endpage()); } if(!isset($_POST['price'])) { echo "The price cannot be empty!"; exit($h->endpage()); } else { $db->query("INSERT INTO `crydeal` VALUES(NULL, ".abs(intval($_POST['crystals'])).", ".abs(intval($_POST['price'])).")"); echo "<span class="highlight">Crystal</span> package added. <a href="http://dealer.php" target="_blank">[View package]</a>"; } } if($ir['user_level'] !=2) { echo "Haha, trying to fool the system?! Just get out of here!"; } else { echo "<form action='?action=add' method='post'> <table width='95%' class='table'> <tr> <td colspan='2' class='h'><center>Add a new package</td> </tr> <tr> <td>Amount of crystals</td> <td><input type='text' name='crystals' length='70'></td> </tr> <tr> <td>Cost (for the package)</td> <td><input type='text' name='price' length='70'></td> </tr> <tr> <td></td> <td align='right'><input type='submit' value='Add package' name='submit' /></td> </tr> </table> </form>"; } } function Buy() { global $h, $ir, $db; if((!isset($_GET['id'])) || !ctype_digit($_GET['id'])) { echo "Invalid use of file"; exit($h->endpage()); } else { $q=$db->query("SELECT * FROM `crydeal` WHERE `id` = ".$_GET['id'].""); if(mysql_num_rows($q) == 0) { echo "Invalid action."; exit($h->endpage()); } else { $cryd=$db->fetch_row($q); if($ir['money'] < $cryd['price']) { echo "You do not have enough Money!"; exit($h->endpage()); } $price=$cryd['price']; $crystals=$cryd['crystals']; echo "You brought ".number_format($cryd['crystals'])." for $".number_format($price).". > <a href="http://explore.php" target="_blank">Back</a>"; $db->query("UPDATE `users` SET `money` = `money` - ".$price.", `crystals` = `crystals` + ".$crystals." WHERE (`userid` = ".$_SESSION['userid'].")"); } } ?> Quote
peterisgb Posted May 20, 2012 Posted May 20, 2012 to be honest the whole script needs to be reworked. Quote
skooda Posted May 20, 2012 Author Posted May 20, 2012 Yea thats what im thinking I alter it and it still doesnt work Quote
Seker Posted May 20, 2012 Posted May 20, 2012 As you're not being too descriptive... Try this: (Untested) <?php /*---------------------------------------------------------- -- Crystal Dealer -- Please DO NOT alter this section -- This page has been developed by David Armstead (Maniak) -- Contact me @ <a href="mailto:[email protected]">david_arm [email protected]</a> ----------------------------------------------------------*/ include_once (DIRNAME(__FILE__) .'/globals.php'); $_GET['action'] = isset($_GET['action']) && ctype_alpha($_GET['action']) ? trim($_GET['action']) : 'index'; switch($_GET['action']) { case 'add': add(); break; case 'Buy': Buy(); break; default: index(); break; } if (!in_array($_GET['action'], array('index', 'add'))) { echo('Invalid Command!'); exit($h->endpage()); } function index() { global $db, $ir, $h; $q=$db->query("SELECT * FROM `crydeal`"); echo "<h3>Crystal Dealer</h3>"; if($ir['user_level'] == 2) { echo "<p align='left'><a href='dealer.php?action=add'>Add crystals to the dealer</a></p>"; } echo "<p align='left'>Welcome to the crystal Dealer. Here you can buy a set amount of crystals from the game for a set price.</p> <table width='50%' class='table'><tr> <td class='h' width='40%'>Number of Crystals</td> <td class='h' width='40%'>Cost</td> <td class='h' width='10%'></td> </tr>"; if(!$db->num_rows($q)) { echo "<tr><td colspan='3' align = 'center'>No crystals for sale here!</td></tr>"; } else { while ($r=$db->fetch_row($q)) { echo "<tr> <td width='40%'>".number_format($r['crystals'])."</td> <td width='40%'>$".number_format($r['price'])."</td> <td width='10%'><a href='dealer.php?action=Buy&id=".$r['id']."'>[buy]</td> </tr>"; } } echo "</table>"; } function add() { global $db, $ir, $h; if(isset($_POST['submit'])) { if(!isset($_POST['crystals'])) { echo "Amount of crystals cannot be empty!"; exit($h->endpage()); } if(!isset($_POST['price'])) { echo "The price cannot be empty!"; exit($h->endpage()); } else { $db->query("INSERT INTO `crydeal` VALUES(NULL, ".abs(intval($_POST['crystals'])).", ".abs(intval($_POST['price'])).")"); echo "Crystal package added. <a href='dealer.php'>[View package]</a>"; } } if($ir['user_level'] !=2) { echo "Haha, trying to fool the system?! Just get out of here!"; } else { echo "<form action='?action=add' method='post'> <table width='95%' class='table'> <tr> <td colspan='2' class='h'><center>Add a new package</td> </tr> <tr> <td>Amount of crystals</td> <td><input type='text' name='crystals' length='70'></td> </tr> <tr> <td>Cost (for the package)</td> <td><input type='text' name='price' length='70'></td> </tr> <tr> <td></td> <td align='right'><input type='submit' value='Add package' name='submit' /></td> </tr> </table> </form>"; } } function Buy() { global $h, $ir, $db; if((!isset($_GET['id'])) || !ctype_digit($_GET['id'])) { echo "Invalid use of file"; exit($h->endpage()); } else { $q=$db->query("SELECT * FROM `crydeal` WHERE `id` = ".$_GET['id'].""); if(mysql_num_rows($q) == 0) { echo "Invalid action."; exit($h->endpage()); } else { $cryd=$db->fetch_row($q); if($ir['money'] < $cryd['price']) { echo "You do not have enough Money!"; exit($h->endpage()); } $price=$cryd['price']; $crystals=$cryd['crystals']; echo "You brought ".number_format($cryd['crystals'])." for $".number_format($price).". <a href='explore.php'>Back</a>"; $db->query("UPDATE `users` SET `money` = `money` - ".$price.", `crystals` = `crystals` + ".$crystals." WHERE (`userid` = ".$_SESSION['userid'].")"); } } ?> Quote
skooda Posted May 20, 2012 Author Posted May 20, 2012 As you're not being too descriptive... Try this: (Untested) <?php /*---------------------------------------------------------- -- Crystal Dealer -- Please DO NOT alter this section -- This page has been developed by David Armstead (Maniak) -- Contact me @ <a href="mailto:[email protected]">david_arm [email protected]</a> ----------------------------------------------------------*/ include_once (DIRNAME(__FILE__) .'/globals.php'); $_GET['action'] = isset($_GET['action']) && ctype_alpha($_GET['action']) ? trim($_GET['action']) : 'index'; switch($_GET['action']) { case 'add': add(); break; case 'Buy': Buy(); break; default: index(); break; } if (!in_array($_GET['action'], array('index', 'add'))) { echo('Invalid Command!'); exit($h->endpage()); } function index() { global $db, $ir, $h; $q=$db->query("SELECT * FROM `crydeal`"); echo "<h3>Crystal Dealer</h3>"; if($ir['user_level'] == 2) { echo "<p align='left'><a href='dealer.php?action=add'>Add crystals to the dealer</a></p>"; } echo "<p align='left'>Welcome to the crystal Dealer. Here you can buy a set amount of crystals from the game for a set price.</p> <table width='50%' class='table'><tr> <td class='h' width='40%'>Number of Crystals</td> <td class='h' width='40%'>Cost</td> <td class='h' width='10%'></td> </tr>"; if(!$db->num_rows($q)) { echo "<tr><td colspan='3' align = 'center'>No crystals for sale here!</td></tr>"; } else { while ($r=$db->fetch_row($q)) { echo "<tr> <td width='40%'>".number_format($r['crystals'])."</td> <td width='40%'>$".number_format($r['price'])."</td> <td width='10%'><a href='dealer.php?action=Buy&id=".$r['id']."'>[buy]</td> </tr>"; } } echo "</table>"; } function add() { global $db, $ir, $h; if(isset($_POST['submit'])) { if(!isset($_POST['crystals'])) { echo "Amount of crystals cannot be empty!"; exit($h->endpage()); } if(!isset($_POST['price'])) { echo "The price cannot be empty!"; exit($h->endpage()); } else { $db->query("INSERT INTO `crydeal` VALUES(NULL, ".abs(intval($_POST['crystals'])).", ".abs(intval($_POST['price'])).")"); echo "Crystal package added. <a href='dealer.php'>[View package]</a>"; } } if($ir['user_level'] !=2) { echo "Haha, trying to fool the system?! Just get out of here!"; } else { echo "<form action='?action=add' method='post'> <table width='95%' class='table'> <tr> <td colspan='2' class='h'><center>Add a new package</td> </tr> <tr> <td>Amount of crystals</td> <td><input type='text' name='crystals' length='70'></td> </tr> <tr> <td>Cost (for the package)</td> <td><input type='text' name='price' length='70'></td> </tr> <tr> <td></td> <td align='right'><input type='submit' value='Add package' name='submit' /></td> </tr> </table> </form>"; } } function Buy() { global $h, $ir, $db; if((!isset($_GET['id'])) || !ctype_digit($_GET['id'])) { echo "Invalid use of file"; exit($h->endpage()); } else { $q=$db->query("SELECT * FROM `crydeal` WHERE `id` = ".$_GET['id'].""); if(mysql_num_rows($q) == 0) { echo "Invalid action."; exit($h->endpage()); } else { $cryd=$db->fetch_row($q); if($ir['money'] < $cryd['price']) { echo "You do not have enough Money!"; exit($h->endpage()); } $price=$cryd['price']; $crystals=$cryd['crystals']; echo "You brought ".number_format($cryd['crystals'])." for $".number_format($price).". <a href='explore.php'>Back</a>"; $db->query("UPDATE `users` SET `money` = `money` - ".$price.", `crystals` = `crystals` + ".$crystals." WHERE (`userid` = ".$_SESSION['userid'].")"); } } ?> I get the same internal error Quote
Seker Posted May 20, 2012 Posted May 20, 2012 I get the same internal error Your file permission isn't 777, is it? Also, you need another } right before the ?>. Quote
skooda Posted May 20, 2012 Author Posted May 20, 2012 Your file permission isn't 777, is it? Also, you need another } right before the ?>. thanks seeker i really needed this to lower money down Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.