Pudgemeister Posted April 13, 2007 Share Posted April 13, 2007 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 ) Link to comment https://forums.phpfreaks.com/topic/46839-solved-pudgemeister-returns/ Share on other sites More sharing options...
MadTechie Posted April 13, 2007 Share Posted April 13, 2007 Hints in the name.. in a function you need to say what to return change <?php 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; } } return $vehicle_build_time; // <-----ADD THIS ?> i did the same thing when i started.. curse the VB syntax Link to comment https://forums.phpfreaks.com/topic/46839-solved-pudgemeister-returns/#findComment-228310 Share on other sites More sharing options...
Pudgemeister Posted April 13, 2007 Author Share Posted April 13, 2007 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 Link to comment https://forums.phpfreaks.com/topic/46839-solved-pudgemeister-returns/#findComment-228413 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.