Jump to content

Pudgemeister

Members
  • Posts

    94
  • Joined

  • Last visited

Everything posted by Pudgemeister

  1. 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 =)
  2. 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 =)
  3. 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
  4. 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
  5. 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
  6. 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
  7. 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
  8. 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
  9. 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
  10. 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
  11. 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
  12. 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?
  13. 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
  14. 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
  15. 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
  16. Hi again all my php/mysql project is coming along a treat now but ive hit a snag-my function which shouldnt EVER be able to return 0 or '', is returning '' (nothing) 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 * $vehicle_base_build_time; } else { $vehicle_build_time = $vehicle_base_build_time; } } //-------------------------------------------------------------------------------------------------------------------------// //Light Ore Miner// $light_ore_miner_build_time = vehicle_build_times($light_ore_miner_base_build_time,$research_levels['simple_ore_drill_turbines']); //---------------// ?> now the thing is-in the database-ALL the $research_levels fields in the database have 0 in them-so that means when the function is called from this file (inc_vehicle_stats.inc.php) after it has been included in the main file, it should execute the else part of the code-which obviously means in this case with the $light_ore_miner_base_build_time variable it should be returning 600 what is the prob-i know its gona be a simple thing to correct probably but can u explain it as well please thank you for reading Pudgemeister p.s. i know im using insanely long variable names-this is just so i can understand everythin and not get lost-once everything is finished i will hopefully be sizing them all down (oh that will be fun :S )
  17. nethnet-right on all acounts. that rouge m was because of what you said a few posts above and the double equals sign i forgot i had put in there has fixed the error im getting. the page runs normally now-and that rouge m has dissapeared and is finally displaying only numbers that are in the database. thank you all-u were ver helpful...and amusing in ur dissagreements hehehe cheers Pudgemeister
  18. You Are Now Logged In Pudgemeister. Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/pudgesuk/public_html/game_testing/island_home.php on line 13 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/pudgesuk/public_html/game_testing/island_home.php on line 14 thats the error i get when taking them outof the single quote marks-the code looks like this now: [code] <?php session_start(); if(empty($_SESSION['username']) or empty($_SESSION['id']) or empty($_SESSION['password'])) {//if there is nothing in the session echo 'you are not logged in'; exit;//quit the page so they cant view anything else }else{ echo 'You Are Now Logged In '; echo $username; echo '.'; include ('dbinfo.inc.php'); $sql_1="SELECT * FROM user_buildings WHERE username == '$username' AND password == '$password'"; $result_1=mysql_query($sql_1); $num_1=mysql_num_rows($result_1); $row_1=mysql_fetch_array($result_1); echo '<br><a href="buildings/mining_depot.php"><img src="images/buildings/mining_depot.png" alt="Mining Depot"></a>'; echo '<br>Level '; echo $row_1['mining_depot']; } ?> [/code]
  19. thanx for that but this site is here for help, not hinderence or people crying supposedly. neway yeh the current code for the page that displays level m is: island_home.php: [code] <?php session_start(); if(empty($_SESSION['username']) or empty($_SESSION['id']) or empty($_SESSION['password'])) {//if there is nothing in the session echo 'you are not logged in'; exit;//quit the page so they cant view anything else }else{ echo 'You Are Now Logged In '; echo $username; echo '.'; include ('dbinfo.inc.php'); $sql_1 = "SELECT * FROM user_buildings WHERE username == '$username' AND password == '$password'"; $result_1 = mysql_query($sql_1); $num_1 = 'mysql_num_rows($result_1)'; $row_1 = 'mysql_fetch_assoc($result_1)'; echo '<br><a href="buildings/mining_depot.php"><img src="images/buildings/mining_depot.png" alt="Mining Depot"></a>'; echo '<br>Level '; echo $row_1['mining_depot']; } ?> [/code]
  20. look guys-the switching between array and assoc didnt do nething-il leave u to argue about it. ginger robot: im slightly confused about what you are saying, any way u cud edit my code and put what u sed into action into it so i can see and uderstand for myself? cheers Pudgemeister
  21. [quote] Oh, and drop the rubbish about protecting your secret project. If you want help you have to be willing to tell people what you are trying to achieve and give all the information. [/quote] yeh ur right-theres just a few peeps i dont want finding out and they know i use this site alot. ok thanx for ur hep il try both those waysn and report back. what does fetch assoc do neway?
  22. ARG THIS IS SOO CONFUSING! i got a mate whos a great hacker who is rackin his brains and another doing the same as hs been college n all. god its so WEIRD!!!!! we need sum1 uber pro here
  23. ok the outcome i want is for it to echo level and then the number in the field mining_depot in the database table user_buildings
  24. this has helped me alot peeps-thanx for postin this topic
  25. ive also taken out the encryption to make sure-it still returns m
×
×
  • 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.