Pudgemeister
Members-
Posts
94 -
Joined
-
Last visited
About Pudgemeister
- Birthday 09/12/1989
Contact Methods
-
AIM
none
-
MSN
pudge004@gmail.com
-
Website URL
http://www.pudgespages.co.uk
-
Yahoo
none
Profile Information
-
Gender
Not Telling
-
Location
Cornwall, England, UK,
Pudgemeister's Achievements
Member (2/5)
0
Reputation
-
Hi Jessica, I actually came back to say I'd sorted the problem-and what you have done above is what I tried =D. Thanks for replying - I should think before asking next time hehe. Thank you =)
-
Hi all, I've got an error I have yet to come across. "Strict Standards: Only variables should be passed in reference in my/file/name/here.php on line 69" It was quite a long line of code so by separating it out I have found the problem to lie here: $var = end(explode(".", $_FILES["file"]["name"])); It's not code breaking at all-but I am one for trying to be strict with my standards and making sure I get no notices or warnings let alone errors. Just interested in what I am not understanding. Thanks =)
-
OOPHP __construct class instantiate.
Pudgemeister replied to Pudgemeister's topic in PHP Coding Help
Thanks again guys-both of those explanations have helped me more than php.net or any other tutorial about autoloading This topic can be put as solved now...not sure if I do that or a mod does it-will check to see. Thanks -
OOPHP __construct class instantiate.
Pudgemeister replied to Pudgemeister's topic in PHP Coding Help
Many thanks to you both. I had indeed come across autoloading in my searches for a solution-the problem I have with it is that I cannot for the life of me understand what it is doing/what it means etc. I feel like a fool for it :-\ I don't know why I didn't think about passing it through...that's a herp a derp moment for me there. I will be taking that route ^^ The simple solution is something I had already tried but it didn't work...I may have issues elsewhere. Thanks guys-you were a big help -
Hi All, BORING INTRODUCTION It's been many years since I was here-back when I last posted on phpfreaks I was but in my early teens and learning procedural php. I have since been through college, uni, and a decent web programming job where I have broadened my knowledge significantly to the point of doing everything in OOPHP . I know enough to get by but with some personal projects I am now working on I require a greater understanding of OOPHP (including calling things what they are e.g. object, method, property, etc (I always got mixed up with these). Apologies if what is below is a moment...but sometimes I don't quite understand what is written on these sites. THE PROBLEM I have my own simple custom DBAL. It works. I am now creating a class that needs the DBAL. The DBAL class file and class name are saved in a separate config file as constants. Something I have never been sure how to do (if possible) is if you can do the following: The class that needs DBAL access (separate file): public function __construct() { require('cfg.php'); require(DBAL_CLASS); $this->dbal = new DBAL_CLASS_NAME; } cfg.php <?php //Simpler directory desperator define('DS', DIRECTORY_SEPARATOR); //DBAL define('DBAL_CLASS', $_SERVER['DOCUMENT_ROOT'] . DS . 'db' . DS . 'index.php'); //Name of DBAL define('DBAL_CLASS_NAME', 'db'); A few things: The file name and directory for the DBAL is correct. I have tested echo'ing the constants in the class requiring the DBAL and they are point to the correct place. The only issue with this is that the path for the directory starts off using / and then DS goes to using \. Would this be an issue? I am aware that using constants in this way does not work. I have since edited this to assign the constants to variables as a temporary solution to that part, but I am still having problems. As I have mentioned above I am not from an OOP background and am doing my best to get to grips with it as I can see it's benefits over procedural and enjoy programming like this. LONG STORY SHORT I can't instantiate the class in the construct as I am trying there-well it won't work anyway. I am doing the exact same thing with another class in another file only a few lines later which works perfectly (i.e. I call methods from this other class in further methods in the current class). What have I done wrong? What could I do better? What is laughable? What have I done right? Any pro's and/or cons about the above would be greatly appreciated As I said above-a mixture of simple and not so simple stuff (or so it seems to me ). Thanks in advance, Pudgemeister
-
hi guys im using frames in my php script (no comments XD) i got a top frame that contains the logo and links, and then the bottom, bigger frame that displays the pages that the links are linked to. the thing is-i want the top frame to refresh every time a link is clicked how is this done? Pudgemeister
-
[SOLVED] function variable problems-this might take a while
Pudgemeister replied to Pudgemeister's topic in PHP Coding Help
wtf?? now everythin is workin and that solution u gave me works fine i think my wamp server has had sumit up wid it for a while but hey i aint complainin-ur solution works now cheers keeping topic undolved cus the function aint complete yet Pudgemeister -
[SOLVED] function variable problems-this might take a while
Pudgemeister replied to Pudgemeister's topic in PHP Coding Help
umm ok sumit weird is happenin here now :S ive just done sum testing and i tihnk sumit is up wid my wamp package or sumthin cus when I do: <?php $test = 'test'; echo $test; ?> im getin no output! this is slightly worrying-have a made a very stupid mistake sumwhere -
[SOLVED] function variable problems-this might take a while
Pudgemeister replied to Pudgemeister's topic in PHP Coding Help
hmmmmm thats weird-im gona go over everythin now-il message again for other probs or if this stil isnt fixed :S i shal also try the way u tested-ty for your continued help -
[SOLVED] function variable problems-this might take a while
Pudgemeister replied to Pudgemeister's topic in PHP Coding Help
stil getting: Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting T_VARIABLE or '$' in C:\wamp\www\game\vehicles\vehicle_build_times.inc.php on line 141 -
[SOLVED] function variable problems-this might take a while
Pudgemeister replied to Pudgemeister's topic in PHP Coding Help
atm it's starting at the first line where im trying to use a variable variable $available_construction = $seconds_since / ${$vehicle}_build_time; is now in place of $available_construction = $seconds_since / $'$vehicle'_build_time; and it's the same for other places like that -
[SOLVED] function variable problems-this might take a while
Pudgemeister replied to Pudgemeister's topic in PHP Coding Help
ok ive replaced any of those stupid lookin $'$vehicle'_build_time variables with ${$vehicle}_build_time variable names according to the info page you gave me (which is now bookmarked-tyvm) this should be correct im still getting the same error :S the error is: Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting T_VARIABLE or '$' in C:\wamp\www\game\vehicles\vehicle_build_times.inc.php on line 141 i even get that error with a simple variable in place of the variable variable. i can't see the problem :S whats up? -
[SOLVED] function variable problems-this might take a while
Pudgemeister replied to Pudgemeister's topic in PHP Coding Help
aha ty u found what i couldnt i shall begin testing this but this topic isn't solved yet as tehre are many more probs (im guessin) with this code -
yes...tis me again...hello all *dodges rotten tomatoes* i got probs *surprise surprise* first of all here is the code: <?php $research_levels_query = "SELECT * FROM research WHERE username = '$username' AND password = '$password'"; $activate_query = mysql_query($research_levels_query) or die(mysql_error()); $research_levels = mysql_fetch_assoc($activate_query) or die(mysql_error()); //base build times for all vehicles in seconds// $light_ore_miner_base_build_time = 600; $light_fuel_miner_base_build_time = 720; $light_crystal_miner_base_build_time = 900; $light_wood_farmer_base_build_time = 660; $light_wave_sub_base_build_time = 840; $light_atmospheric_filterer_base_build_time = 960; $medium_ore_miner_base_build_time = 3000; $medium_fuel_miner_base_build_time = 3420; $medium_crystal_miner_base_build_time = 3900; $medium_wood_farmer_base_build_time = 3300; $medium_wave_sub_base_build_time = 3540; $medium_atmospheric_filterer_base_build_time = 4020; $heavy_ore_miner_base_build_time = 7800; $heavy_fuel_miner_base_build_time = 8400; $heavy_crystal_miner_base_build_time = 9000; $heavy_wood_farmer_base_build_time = 8100; $heavy_wave_sub_base_build_time = 8700; $heavy_atmospheric_filterer_base_build_time = 9600; //----------------------------------------------CREATE FUNCTION------------------------------------------------------------// function vehicle_build_times($vehicle_base_build_time,$research_level) { if ($research_level >= 1) { $vehicle_build_time = $research_level - (5 * ($vehicle_base_build_time / 100)); } else { $vehicle_build_time = $vehicle_base_build_time; } return $vehicle_build_time; } //-------------------------------------------------------------------------------------------------------------------------// //-----------------------------------------------------ECONOMIC VEHICLE BUILD TIME FUNCTIONS--------------------------------------------------// //Light Ore Miner// $light_ore_miner_build_time = vehicle_build_times($light_ore_miner_base_build_time,$research_levels['simple_ore_drill_turbines']); //---------------// //Light Fuel Miner// $light_fuel_miner_build_time = vehicle_build_times($light_fuel_miner_base_build_time,$research_levels['simple_fuel_drill_turbines']); //----------------// //Light Crystal Miner// $light_crystal_miner_build_time = vehicle_build_times($light_crystal_miner_base_build_time,$research_levels['simple_crystal_drill_turbines']); //-------------------// //Light Wood Farmer// $light_wood_farmer_build_time = vehicle_build_times($light_wood_farmer_base_build_time,$research_levels['simple_farm_fertilisation']); //-----------------// //Light Wave Sub// $light_wave_sub_build_time = vehicle_build_times($light_wave_sub_base_build_time,$research_levels['simple_wave_turbines']); //--------------// //Light Atmospheric Filterer// $light_atmospheric_filterer_build_time = vehicle_build_times($light_atmospheric_filterer_base_build_time,$research_levels['simple_atmospheric_filter_enlarger']); //--------------------------// //Medium Ore Miner// $medium_ore_miner_build_time = vehicle_build_times($medium_ore_miner_base_build_time,$research_levels['advanced_ore_drill_turbines']); //---------------// //Medium Fuel Miner// $medium_fuel_miner_build_time = vehicle_build_times($medium_fuel_miner_base_build_time,$research_levels['advanced_fuel_drill_turbines']); //----------------// //Medium Crystal Miner// $medium_crystal_miner_build_time = vehicle_build_times($medium_crystal_miner_base_build_time,$research_levels['advanced_crystal_drill_turbines']); //-------------------// //Medium Wood Farmer// $medium_wood_farmer_build_time = vehicle_build_times($medium_wood_farmer_base_build_time,$research_levels['advanced_farm_fertilisation']); //-----------------// //Medium Wave Sub// $medium_wave_sub_build_time = vehicle_build_times($medium_wave_sub_base_build_time,$research_levels['advanced_wave_turbines']); //--------------// //Medium Atmospheric Filterer// $medium_atmospheric_filterer_build_time = vehicle_build_times($medium_atmospheric_filterer_base_build_time,$research_levels['advanced_atmospheric_filter_enlarger']); //--------------------------// //Heavy Ore Miner// $heavy_ore_miner_build_time = vehicle_build_times($heavy_ore_miner_base_build_time,$research_levels['hi_tech_ore_drill_turbines']); //---------------// //Heavy Fuel Miner// $heavy_fuel_miner_build_time = vehicle_build_times($heavy_fuel_miner_base_build_time,$research_levels['hi_tech_fuel_drill_turbines']); //----------------// //Heavy Crystal Miner// $heavy_crystal_miner_build_time = vehicle_build_times($heavy_crystal_miner_base_build_time,$research_levels['hi_tech_crystal_drill_turbines']); //-------------------// //Heavy Wood Farmer// $heavy_wood_farmer_build_time = vehicle_build_times($heavy_wood_farmer_base_build_time,$research_levels['hi_tech_farm_fertilisation']); //-----------------// //Heavy Wave Sub// $heavy_wave_sub_build_time = vehicle_build_times($heavy_wave_sub_base_build_time,$research_levels['hi_tech_wave_turbines']); //--------------// //Heavy Atmospheric Filterer// $heavy_atmospheric_filterer_build_time = vehicle_build_times($heavy_atmospheric_filterer_base_build_time,$research_levels['hi_tech_atmospheric_filter_enlarger']); //--------------------------// //------------------------------------------------------------------------------------------------------------------------------------------------// //CREATE UPDATE VEHICLE QUE FUNCTION// function update_vehicle_que($vehicle,) { //query to add the que'd vehicles and added to que light_ore_miner's together and put into the database $add_to_que = "UPDATE vehicle_construct_amount SET $vehicle = '$light_ore_miner' WHERE username='$username' AND password='$password'"; //get the current timestamp $current_timestamp = time(); //If There are currently 0 of this certain vehicle in the que for build-add them if ($fetch_timestamp['$vehicle'] == 0) { $add_date_and_time = "UPDATE vehicle_construct_seconds SET $vehicle = '$current_timestamp' WHERE username = '$username' AND password = '$password'"; mysql_query($add_date_and_time) or die(mysql_error()); mysql_query($add_to_que) or die(mysql_error()); } else { //find out how many seconds has passed while they have been in the que $seconds_since = time() - $fetch_timestamp['$vehicle']; //work out how many could have been created $available_construction = $seconds_since / $'$vehicle'_build_time; //if all the que'd selected vehicle have finished-update the tables if ($available_construction > $grabbed_vehicles_construction_amounts['$vehicle']) { //end the vehicle que $update_que = "UPDATE vehicle_construct_amount SET $vehicle = '0' WHERE username = '$username' AND password = '$password'"; //reset the timestamp $update_timestamp = "UPDATE vehicle_construct_seconds SET $vehicle = '0' WHERE username = '$username' AND password = '$password'"; //add current selected vehicles to already built light_ore_miners $total_'$vehicle' = $grabbed_vehicle_amounts['$vehicle'] + $grabbed_vehicles_construction_amounts['$vehicle']; //query to update the vehicles table with the new created current vehicle amount $update_vehicles = "UPDATE vehicle_amounts SET $vehicle = '$total_'$vehicle'' WHERE username = '$username' AND password = '$password'"; //activate the queries mysql_query($update_vehicles) or die(mysql_error()); mysql_query($update_que) or die(mysql_error()); mysql_query($update_timestamp) or die(mysql_error()); } else { //take off any remainder from end result of the above processes $sums_remainder = $available_construction - floor($available_construction); $available_build = $available_construction - $sums_remainder; if ($available_build >= 1) { //update current vehicle que if ($grabbed_vehicles_construction_amounts['$vehicle'] >= 1) { $grabbed_'$vehicle' = $grabbed_vehicles_construction_amounts['$vehicle'] - $available_build; //put into query '$vehicle'_update = "UPDATE vehicle_construct_amount SET $vehicle = '$grabbed_'$vehicle'' WHERE username = '$username' AND password = '$password'"; mysql_query('$vehicle'_update) or die(mysql_error()); } //add ready current vehicles to list of already constructed $constructed_'$vehicle' = $grabbed_vehicle_amounts['$vehicle'] + $available_construction; //put this into query $update_table = "UPDATE vehicle_amount SET $vehicle = '$constructed_'$vehicle'' WHERE username = '$username' AND password = '$password'"; //make a new timestamp including the remainder for the current vehicle in production $timestamp_remainder = $sums_remainder * 600; $required_timestamp = time() - $timestamp_remainder; //put into query $insert_timestamp = "UPDATE vehicle_construct_seconds SET $vehicle = '$required_timestamp' WHERE username = '$username' AND password = '$password'"; //activate queries mysql_query($update_table) or die(mysql_error()); mysql_query($insert_timestamp) or die(mysql_error()); } } } } ?> now if i can explain this right u may b able to help me as u can see it is a game i am making neway-the prob is im trying to use the $vehicle variable to make the names of other variables inside the function e.g. $'$vehicle'_build_time obviously ive found out that this doesn't work unfortunately is there any way of doing what i wana do in php? or is it much more complicated than what im trying to do? cheers Pudgemeister
-
yes i did notice ye ol vb syntax feeling coming over me and u wandered why i was turning emo while coding this part XD jks cheers-all works fine now Pudgemeister p.s. i shall no doubt be back with more function problems in the future as the next part to this project includes mainly functions-i only learnt how to use the basics of them 2 days ago XD