Jump to content

need help...


Day Walker

Recommended Posts

Unless the file is bogged with errors, you shouldn't need to post the entire page.  The error message will tell you which file and line the error is generated by.  Then just post that line (and maybe relevant code such as if it's part of an if statement).  This is, of course, assuming you are using a method to echo errors...
Link to comment
Share on other sites

well...the line it is telling me there is an error on is correct...it is after i added the other section that i now get the error...it says it is calling to an undefined object...the piece i added is kinda long and i think i made a mistake or two...as i said i am a n00b just trying to learn...i'll post the section here if i may...
Link to comment
Share on other sites

Generic-
You don't like reading through a billion lines of code?

Not to hijack!  But please do post your code...and try to localize it as Genericnumber1 said...because we're lazy and don't want to read more than 3 or 4 lines.  :P

Well, I am anyway.
Link to comment
Share on other sites

:o

Okay.  Well, try this.  Make a backup copy of the file and start doing some test.  Work your way from the bottom removing relevant blocks of code at a time and running the script with each edit.  Or, alternatively, remove all of the code after the point which you KNOW works, then slowly add one segment at a time, running the script again each time you add a new segment until you receive an error again.
Link to comment
Share on other sites

Stick that 232 section in  code tags... and I'll just let my IDE debug it then ? no promises though, big chunks of code make me gag.

I'm surprised that you couldn't localize the problem to a smaller area than that? Tell us what the error is and we may not even have to see code, unless it's something like "unexpected BLAH"
Link to comment
Share on other sites

the error i get is :Fatal error: Call to a member function on a non-object in /home/bloodshe/public_html/BLOODSHEDDdev/global_funcs.php on line 374
however this error never happened till after i added this: starting @ line(513)

new block quoted...
/*
$torps = 90;
$fighters = 100;
$armor = 150;
$energy = 200;
$spy = 300;
$wormhole = 350;
$sg = 500;
$nova = 550;

$torps_trigger = floor($torps / 2);
$fighters_trigger = floor($fighters / 2);
$armor_trigger = floor($armor / 2);
$energy_trigger = floor($energy / 2);
$spy_trigger = floor($spy / 2);
$wormhole_trigger = floor($wormhole / 2);
$sg_trigger = floor($sg_torp / 2);
$nova_trigger = floor($nova / 2);

$flag = 1;

$amount = round($credits * (mt_rand(($deathlostpercent / 2), $deathlostpercent) / 100));

$debug_query = $db->Execute("UPDATE $dbtables[players] SET credits=credits-$amount WHERE player_id=$player_id");
db_op_result($debug_query,__LINE__,__FILE__);

$debris_type = 14;
$debris_data = $amount;

$findem = $db->Execute("SELECT sector_id FROM $dbtables[universe]");
$totrecs=$findem->RecordCount();
$getit=$findem->GetArray();

$randplay=mt_rand(0,($totrecs-1));
$targetlink = $getit[$randplay]['sector_id'];
$debug_query = $db->Execute("INSERT INTO $dbtables[debris] (debris_type, debris_data, sector_id) values ($debris_type,'$debris_data', $targetlink)");
db_op_result($debug_query,__LINE__,__FILE__);

$success = mt_rand(0, $torps);
if ($success == $torps_trigger && $flag)
{
$debris_type = 2;
$debris_data = 1;
if(mt_rand(0, 1) == 1)
$debris_data = -1 * $debris_data;
$flag = 0;
}

$success = mt_rand(0, $fighters);
if ($success == $fighters_trigger && $flag)
{
$debris_type = 3;
$debris_data = 1;
if(mt_rand(0, 1) == 1)
$debris_data = -1 * $debris_data;
$flag = 0;
}

$success = mt_rand(0, $armor);
if ($success == $armor_trigger && $flag)
{
$debris_type = 4;
$debris_data = 1;
if(mt_rand(0, 1) == 1)
$debris_data = -1 * $debris_data;
$flag = 0;
}

$success = mt_rand(0, $energy);
if ($success == $energy_trigger && $flag)
{
$debris_type = 5;
$debris_data = 1;
if(mt_rand(0, 1) == 1)
$debris_data = -1 * $debris_data;
$flag = 0;
}

$success = mt_rand(0, $spy);
if ($success == $spy_trigger && $flag)
{
$debris_type = 7;
$debris_data = 1;
if(mt_rand(0, 1) == 1)
$debris_data = -1 * $debris_data;
$flag = 0;
}

$success = mt_rand(0, $wormhole);
if ($success == $wormhole_trigger && $flag)
{
$debris_type = 8;
$debris_data = 1;
$flag = 0;
}

$success = mt_rand(0, $sg);
if ($success == $sg_trigger && $flag)
{
$debris_type = 11;
$debris_data = 1;
if(mt_rand(0, 1) == 1)
$debris_data = -1 * $debris_data;
$flag = 0;
}

$success = mt_rand(0, $nova);
if ($success == $nova_trigger && $flag)
{
$debris_type = 12;
$debris_data = 1;
if(mt_rand(0, 1) == 1)
$debris_data = -1 * $debris_data;
$flag = 0;
}

if ($flag)
{
$debris_type = 0;
$debris_data = 0;
}

$randplay=mt_rand(0,($totrecs-1));
$targetlink = $getit[$randplay]['sector_id'];
$debug_query = $db->Execute("INSERT INTO $dbtables[debris] (debris_type, debris_data, sector_id) values ($debris_type,'$debris_data', $targetlink)");
db_op_result($debug_query,__LINE__,__FILE__);
}
} //To here was original...i added following and will set values later...but now i get the error...what did i do wrong?

$torps = 90;
$fighters = 100;
$armor = 150;
$energy = 200;
$spy = 300;
$wormhole = 350;
$sg = 500;
$nova = 550;

$torps_trigger = floor($torps / 2);
$fighters_trigger = floor($fighters / 2);
$armor_trigger = floor($armor / 2);
$energy_trigger = floor($energy / 2);
$spy_trigger = floor($spy / 2);
$wormhole_trigger = floor($wormhole / 2);
$sg_trigger = floor($sg_torp / 2);
$nova_trigger = floor($nova / 2);

$flag = 1;

$amount = round($credits * (mt_rand(($deathlostpercent / 2), $deathlostpercent) / 100));

$debug_query = $db->Execute("UPDATE $dbtables[players] SET credits=credits-$amount WHERE player_id=$player_id");
db_op_result($debug_query,__LINE__,__FILE__);

$asteroids_type = 14;
$asteroids_data = $amount;

$findem = $db->Execute("SELECT sector_id FROM $dbtables[universe]");
$totrecs=$findem->RecordCount();
$getit=$findem->GetArray();

$randplay=mt_rand(0,($totrecs-1));
$targetlink = $getit[$randplay]['sector_id'];
$debug_query = $db->Execute("INSERT INTO $dbtables[asteroids] (asteroids_type, asteroids_data, sector_id) values ($asteroids_type,'$asteroids_data', $targetlink)");
db_op_result($debug_query,__LINE__,__FILE__);

$success = mt_rand(0, $torps);
if ($success == $torps_trigger && $flag)
{
$asteroids_type = 2;
$asteroids_data = 1;
if(mt_rand(0, 1) == 1)
$asteroids_data = -1 * $asteroids_data;
$flag = 0;
}

$success = mt_rand(0, $fighters);
if ($success == $fighters_trigger && $flag)
{
$asteroids_type = 3;
$asteroids_data = 1;
if(mt_rand(0, 1) == 1)
$asteroids_data = -1 * $asteroids_data;
$flag = 0;
}

$success = mt_rand(0, $armor);
if ($success == $armor_trigger && $flag)
{
$asteroids_type = 4;
$asteroids_data = 1;
if(mt_rand(0, 1) == 1)
$asteroids_data = -1 * $asteroids_data;
$flag = 0;
}

$success = mt_rand(0, $energy);
if ($success == $energy_trigger && $flag)
{
$asteroids_type = 5;
$asteroids_data = 1;
if(mt_rand(0, 1) == 1)
$asteroids_data = -1 * $asteroids_data;
$flag = 0;
}

$success = mt_rand(0, $spy);
if ($success == $spy_trigger && $flag)
{
$asteroids_type = 7;
$asteroids_data = 1;
if(mt_rand(0, 1) == 1)
$asteroids_data = -1 * $asteroids_data;
$flag = 0;
}

$success = mt_rand(0, $wormhole);
if ($success == $wormhole_trigger && $flag)
{
$asteroids_type = 8;
$asteroids_data = 1;
$flag = 0;
}

$success = mt_rand(0, $sg);
if ($success == $sg_trigger && $flag)
{
$asteroids_type = 11;
$asteroids_data = 1;
if(mt_rand(0, 1) == 1)
$asteroids_data = -1 * $asteroids_data;
$flag = 0;
}

$success = mt_rand(0, $nova);
if ($success == $nova_trigger && $flag)
{
$asteroids_type = 12;
$asteroids_data = 1;
if(mt_rand(0, 1) == 1)
$asteroids_data = -1 * $asteroids_data;
$flag = 0;
}

if ($flag)
{
$asteroids_type = 0;
$asteroids_data = 0;
}

$randplay=mt_rand(0,($totrecs-1));
$targetlink = $getit[$randplay]['sector_id'];
$debug_query = $db->Execute("INSERT INTO $dbtables[asteroids] (asteroids_type, asteroids_data, sector_id) values ($asteroids_type,'$asteroids_data', $targetlink)");
db_op_result($debug_query,__LINE__,__FILE__);
}
}
*/
Link to comment
Share on other sites

lines 366 thru 380

/*
while (!$res2->EOF)
{
$row2 = $res2->fields;
$score += $row2['score2'];
$res2->MoveNext();

}

// End Ship Score loop
  $debug_query = $db->Execute("SELECT credits FROM $dbtables[players] where player_id = $sid");
db_op_result($debug_query,__LINE__,__FILE__);
if ($debug_query)
{
$row = $debug_query->fields;
$score += $row['credits'];
}
*/
Link to comment
Share on other sites

normally what causes this is a variable not being declared...

$db->Execute() would cause this same error if $db wasn't declared.

check to make sure you aren't inside a function/method trying to use a variable not in it's scope... let me give you an example...

[code=php:0]
$db = new db();
function doStuff() {
      $db->Execute('SELECT * FROM table'); // this will flag the same error you have
}
[/code]
Link to comment
Share on other sites

ok...everything ran great till i added from here down (} //To here was original...i added following and will set values later...but now i get the error...what did i do wrong?) in the big chunck i posted...i dont think i added it correctly...db is correct...blah...
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.