Jump to content

phpscriptcoder

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

phpscriptcoder's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. PHP is changing the number to be formatted that way. Also, I noticed that sometimes the number is set to 2 or 3 or 4, not only 0.
  2. UPDATE {{table}} SET `fleet_amount` = '290401619', `fleet_array` = '203,290401619;', `fleet_mess` = '1', `fleet_resource_metal` = '2.42001349167E+15', `fleet_resource_crystal` = '2.42001349167E+15', `fleet_resource_deuterium` = '2.42001349167E+15' WHERE fleet_id = '6772' LIMIT 1 ; I'm not sure if that's the problem, because it works for smaller numbers.
  3. Here is some code. $Mining['metal'] = 0; $Mining['crystal'] = 0; $Mining['deuter'] = 0; ... if ($FleetStorage > 0) { $metal = $TargetPlanet['metal'] / 2; $crystal = $TargetPlanet['crystal'] / 2; $deuter = $TargetPlanet["deuterium"] / 2; if (($metal) > $FleetStorage / 3) { $Mining['metal'] = $FleetStorage / 3; $FleetStorage = $FleetStorage - $Mining['metal']; } else { $Mining['metal'] = $metal; $FleetStorage = $FleetStorage - $Mining['metal']; } if (($crystal) > $FleetStorage / 2) { $Mining['crystal'] = $FleetStorage / 2; $FleetStorage = $FleetStorage - $Mining['crystal']; } else { $Mining['crystal'] = $crystal; $FleetStorage = $FleetStorage - $Mining['crystal']; } if (($deuter) > $FleetStorage) { $Mining['deuter'] = $FleetStorage; $FleetStorage = $FleetStorage - $Mining['deuter']; } else { $Mining['deuter'] = $deuter; $FleetStorage = $FleetStorage - $Mining['deuter']; } } ... $Mining['metal'] = round($Mining['metal']); $Mining['crystal'] = round($Mining['crystal']); $Mining['deuter'] = round($Mining['deuter']); ... $Mining['metal'] = $Mining['metal'] + $FleetRow["fleet_resource_metal"]; $Mining['crystal'] = $Mining['crystal'] + $FleetRow["fleet_resource_crystal"]; $Mining['deuter'] = $Mining['deuter'] + $FleetRow["fleet_resource_deuterium"]; $QryUpdateFleet = "UPDATE {{table}} SET "; $QryUpdateFleet .= "`fleet_amount` = '". $FleetAmount ."', "; $QryUpdateFleet .= "`fleet_array` = '". $FleetArray ."', "; $QryUpdateFleet .= "`fleet_mess` = '1', "; $QryUpdateFleet .= "`fleet_resource_metal` = '". $Mining['metal'] ."', "; $QryUpdateFleet .= "`fleet_resource_crystal` = '". $Mining['crystal'] ."', "; $QryUpdateFleet .= "`fleet_resource_deuterium` = '". $Mining['deuter'] ."' "; $QryUpdateFleet .= "WHERE fleet_id = '". $FleetRow['fleet_id'] ."' "; $QryUpdateFleet .= "LIMIT 1 ;"; doquery( $QryUpdateFleet , 'fleets');
  4. I'm trying to fix someone's game script. It has some code which inserts a new row into the database, and 3 of the fields can be very large (in the quadrillions). But when the row is inserted, the 3 large fields are set to 0. The field types are BIGINT unsigned with length 21. Before being inserted into the database, the number is added to a variable which is often 0, if that matters. Thanks for helping!
  5. Is there anyway to rewrite this code without using a while loop? foreach ( $BuildArray as $Node => $Item ) { if (!$UnFinished) { $Element = $Item[0]; $Count = $Item[1]; $BuildTime = $Item[2]; while (!$UnFinished ) { if ( $Count > 0 ) { $CurrentPlanet['b_hangar'] -= $BuildTime; $Builded[$Element]++; $CurrentPlanet[$resource[$Element]]++; $Count--; if ($Count == 0) { break; } } else { $UnFinished = true; break; } } } if ( $Count != 0 ) { $CurrentPlanet['b_hangar_id'] .= $Element.",".$Count.";"; } } This is in a game script I'm trying to fix up (the code is very bad). The problem is that $Count is often in the millions, and my host has a max_execution_time of 5 seconds. Thanks! I can give more details about the variables if needed.
  6. I visited my site yesterday, and noticed that some of the images were appearing as the alt text on the page. They work if viewed by themself, or with cache disabled. The Web Developer toolbar says there are 0 broken images, and the HTTP header is 200 OK. This only happens on my domain, and yesterday was the first occurrence of the problem (I was gone for a few days, and it worked then). The broken images appear to be picked out at random but they are the same every time. Any ideas?
  7. Probably not the best way but I changed the process_include function to use the variable as a global.
  8. You might want to use a better way of checking the extension. I renamed a php file to .png.php and was able to upload it. So people could upload any file type they want if they rename it.
  9. Is it possible to pass additional arguments to the callback function? My code for the templater so far: <?php function process_include($matches) { return templater(file_get_contents($matches[1]), $vars); } function templater($file, $vars) { $template = file_get_contents(templates.'/'.$file); foreach($vars as $k => $v) { $template = str_replace('[$'.$k.']', $v, $template); } $template = preg_replace_callback('/\{\{([^\}]+)\}\}/', 'process_include', $template); echo $template; } ?> I am calling the templater function recursively so the additional template files will be processed as well. $vars is set in the file calling the templater, and I need to pass it every time the templater is called recursively. Any help?
  10. Hi, I'm trying to make a simple templating system for use in another script. I want to have a feature to include another template file, but am not sure how. This is what I am trying to use ($template is the contents of the template file). $template = preg_replace('/\{\{([^\}]+)\}\}/', file_get_contents('\\\0'), $template); It tries to include the file \\\0 rather than the correct filename. This is supposed to match a string like {{header.html}} and replace it with the contents of the file within the braces. I have tried some different methods, but none of them work. Thanks.
×
×
  • 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.