Jump to content

Unable to find the error.


smithmr8

Recommended Posts

The below script is showing as a blank page for me, which due to the fact that error messages were turned off by my host, means there is something wrong with it. I've gone over it multiple times trying to find it, but to no avail.

 

<?php include('header.php') ?>
<?php
if($_GET['step'] == 'darts'){
echo "<b>El Darto Biro</b><br>";
echo "<i>Try improving your aim by throwing some darts!</i><br><br>";
echo "<a href=thecountryclub.php?step=darts&action=throw>Throw Dart</a> (-2% Energy)<br>";
} elseif ($_GET['step'] == 'darts' & $_GET['action'] == 'throw'){
if($x['energy'] >= 2) {
mysql_query("UPDATE users SET energy=energy-2 WHERE ID=$x[iD]") or die mysql_error();
$chance = rand(0,$x['level']);
if($chance >= 1){
$expgain = $chance;
echo "You successfully threw a dart and gained".$expgain."EXP";
mysql_query("UPDATE users SET exp=exp+$expgain, total_exp=total_exp+$expgain WHERE ID=$x[iD]")or die mysql_error();
if($x['exp'] > ($x['level']*$x['exp_needed']){
$expnumber = ($x['exp_needed']*$x['level']);
mysql_query("UPDATE users SET exp=exp-$expnumber, level=level+1 WHERE ID=$x[iD]")or die mysql_error();
echo "You have gained a level!";
}
} else {
echo "You failed to throw the dart straight and hit someone in the head<br>";
}
} else {
echo "You dont have enough energy to do this.<br>";
}
} else {
echo "<b>The Country Club</b><br><br>";
echo "<a href=thecountryclub.php?step=darts>El Darto Biro</a><br>";
}

?>
<?php include('footer.php') ?>

Link to comment
Share on other sites

I ended up just removing those parts completely. But, its still not working. :/

 

<?php include('header.php') ?>
<?php
if($_GET['step'] == 'darts'){
echo "<b>El Darto Biro</b><br>";
echo "<i>Try improving your aim by throwing some darts!</i><br><br>";
echo "<a href=thecountryclub.php?step=darts&action=throw>Throw Dart</a> (-2% Energy)<br>";
} elseif ($_GET['step'] == 'darts' & $_GET['action'] == 'throw'){
if($x['energy'] >= 2) {
mysql_query("UPDATE users SET energy=energy-2 WHERE ID=$x[iD]");
$chance = rand(0,$x['level']);
if($chance >= 1){
$expgain = $chance;
echo "You successfully threw a dart and gained".$expgain."EXP";
mysql_query("UPDATE users SET exp=exp+$expgain, total_exp=total_exp+$expgain WHERE ID=$x[iD]");

if($x['exp'] > ($x['level']*$x['exp_needed']){
$expnumber = ($x['exp_needed']*$x['level']);
mysql_query("UPDATE users SET exp=exp-$expnumber, level=level+1 WHERE ID=$x[iD]");
echo "You have gained a level!";
}

} else {
echo "You failed to throw the dart straight and hit someone in the head<br>";
}
} else {
echo "You dont have enough energy to do this.<br>";
}
} else {
echo "<b>The Country Club</b><br><br>";
echo "<a href=thecountryclub.php?step=darts>El Darto Biro</a><br>";
}

?>
<?php include('footer.php') ?>

 

Dammit!

Link to comment
Share on other sites

Try removing some parts of code until it reports the error

 

<?php include('header.php') ?>
<?php

error_reporting(E_ALL);

if($_GET['step'] == 'darts')
{

echo "<b>El Darto Biro</b><br>";
echo "<i>Try improving your aim by throwing some darts!</i><br><br>";
echo "<a href=thecountryclub.php?step=darts&action=throw>Throw Dart</a> (-2% Energy)<br>";
}
elseif($_GET['step'] == 'darts' & $_GET['action'] == 'throw')
{
  if($x['energy'] >= 2)
  {
    mysql_query("UPDATE users SET energy=energy-2 WHERE ID=$x[iD]") or die mysql_error();
   $chance = rand(0,$x['level']);
    if($chance >= 1)
{
      $expgain = $chance;
      echo "You successfully threw a dart and gained".$expgain."EXP";
      mysql_query("UPDATE users SET exp=exp+$expgain, total_exp=total_exp+$expgain WHERE ID=$x[iD]")or die mysql_error();
     if($x['exp'] > ($x['level']*$x['exp_needed'])
 {
      $expnumber = ($x['exp_needed']*$x['level']);
      mysql_query("UPDATE users SET exp=exp-$expnumber, level=level+1 WHERE ID=$x[iD]")or die mysql_error();
      echo "You have gained a level!"; 
     }
    }
 else
{
      echo "You failed to throw the dart straight and hit someone in the head<br>";
    }
   }
   else
   {
      echo "You dont have enough energy to do this.<br>";
   }
}
else
{
  echo "<b>The Country Club</b><br><br>";
  echo "<a href=thecountryclub.php?step=darts>El Darto Biro</a><br>";
}

?>
<?php include('footer.php') ?>

Link to comment
Share on other sites

I removed this part, and it does show the page with some error's listed.

 

if($x['energy'] >= 2)
  {
    mysql_query("UPDATE users SET energy=energy-2 WHERE ID=$x[iD]") or die mysql_error();
   $chance = rand(0,$x['level']);
    if($chance >= 1)
{
      $expgain = $chance;
      echo "You successfully threw a dart and gained".$expgain."EXP";
      mysql_query("UPDATE users SET exp=exp+$expgain, total_exp=total_exp+$expgain WHERE ID=$x[iD]")or die mysql_error();
     if($x['exp'] > ($x['level']*$x['exp_needed'])
 {
      $expnumber = ($x['exp_needed']*$x['level']);
      mysql_query("UPDATE users SET exp=exp-$expnumber, level=level+1 WHERE ID=$x[iD]")or die mysql_error();
      echo "You have gained a level!"; 
     }
    }
 else
{
      echo "You failed to throw the dart straight and hit someone in the head<br>";
    }
   }
   else
   {
      echo "You dont have enough energy to do this.<br>";
   }

 

The part causing it not to show the page at all is in this part.

 

The error's were...

Notice: Undefined index: step in /home/template/public_html/beta/thecountryclub.php on line 6

 

Notice: Undefined index: step in /home/template/public_html/beta/thecountryclub.php on line 12

 

Notice: Undefined index: action in /home/template/public_html/beta/thecountryclub.php on line 12

Link to comment
Share on other sites

<?php include('header.php') ?>
<?php
if($_GET['step'] == 'darts'){
echo "<b>El Darto Biro</b><br>";
echo "<i>Try improving your aim by throwing some darts!</i><br><br>";
echo "<a href=thecountryclub.php?step=darts&action=throw>Throw Dart</a> (-2% Energy)<br>";
} elseif ($_GET['step'] == 'darts' & $_GET['action'] == 'throw'){
if($x['energy'] >= 2) {
mysql_query("UPDATE users SET energy=energy-2 WHERE ID=$x[iD]") or die (mysql_error());
$chance = rand(0,$x['level']);
if($chance >= 1){
$expgain = $chance;
echo "You successfully threw a dart and gained".$expgain."EXP";
mysql_query("UPDATE users SET exp=exp+$expgain, total_exp=total_exp+$expgain WHERE ID=$x[iD]")or die (mysql_error());
if($x['exp'] > ($x['level']*$x['exp_needed'])){
$expnumber = ($x['exp_needed']*$x['level']);
mysql_query("UPDATE users SET exp=exp-$expnumber, level=level+1 WHERE ID=$x[iD]")or die (mysql_error());
echo "You have gained a level!";
}
} else {
echo "You failed to throw the dart straight and hit someone in the head<br>";
}
} else {
echo "You dont have enough energy to do this.<br>";
}
} else {
echo "<b>The Country Club</b><br><br>";
echo "<a href=thecountryclub.php?step=darts>El Darto Biro</a><br>";
}

?>
<?php include('footer.php') ?>

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.