Jump to content


  • Content Count

  • Joined

  • Last visited

  • Days Won


fastsol last won the day on July 26 2015

fastsol had the most liked content!

Community Reputation

39 Good

About fastsol

  • Rank
    Prolific Member
  • Birthday 10/17/1978

Contact Methods

  • Website URL

Profile Information

  • Gender
  • Location

Recent Profile Visitors

203,046 profile views
  1. fastsol

    Why don't these var_dumps match

    Thank you for the explanation. It's certainly something I've not encountered. This was supposed to be a simple sales tax couple functions that someone found that under certain sets of numbers it was off by 1 cent cause it wasn't rounding up for those instances. I messed around a bit more and got this to work so far and seems to product the correct amounts for a few different values. The functions are identical to what I was running before except I changed the 2nd param of the round() to a 3 instead of 2. Unless you feel this will cause other major issues, I'll probably run with this until I can implement a money type library. // Returns formatted number with sales tax added function addSalesTax($num, $rate) { return number_format(round(($num * $rate), 3), 2); } // Returns just the tax amount function calculateTax($num, $rate) { return number_format(round((($num * $rate) - $num), 3), 2); } $num = 635.00; $num2 = 583.00; $rate = 1.05500; echo addSalesTax($num, $rate); echo '<br>'; echo calculateTax($num, $rate); echo '<br><br>'; echo addSalesTax($num2, $rate); echo '<br>'; echo calculateTax($num2, $rate);
  2. I'm fighting with a very simple round() that isn't giving me the correct output. In the example below the first var_dump shows the value of the calculation performed. The calculation is correct. Next it runs through the round() native function and comes out incorrect. Then I run a round() again but set another var to the same value as the first calculation but by simply setting the number rather than letting php do the math. Then run it through the round() and it comes out to what I expect it should be. So why is the first one not coming out right? $num = 583.00; $rate = 1.05500; $t = (($num * $rate) - $num); var_dump($t); //comes out 32.065 float CORRECT $just_tax = round($t, 2); var_dump($just_tax); //comes out 32.06 float INCORRECT should be 32.07 $t2 = 32.065; //Explicitly set the same value as $t above $just_tax2 = round($t2, 2); var_dump($just_tax2); //comes out 32.07 float CORRECT
  3. Yes the id was the same no matter what I did. That was one of my thoughts too, but led me nowhere.
  4. I don't think this has anything to do with it, but there are some new lines in my htaccess that CPanel added during an update, but even if I comment out the lines it still doesn't work. ########################### RewriteCond %{HTTP_HOST} ^www.mydomain.com$ [NC] RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ RewriteRule ^(.*)$ http://mydomain.com/$1 [R=301,L] ########################### ########################### RewriteCond %{SCRIPT_FILENAME} !-d RewriteCond %{SCRIPT_FILENAME} !-f RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ RewriteRule ^location/(.*)$ ./location-details.php?loc=$1 ########################### RewriteCond %{QUERY_STRING} ^product_id=(.*)$ RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ RewriteRule . %{REQUEST_URI}?product-id=%1 [R=301,L] RewriteBase / RewriteCond %{HTTP:Cookie} devicePixelRatio [NC] RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ RewriteRule \.(?:jpe?g|gif|png|bmp)$ /retinaimages.php [NC,L] RewriteCond %{REQUEST_FILENAME} !-s RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ RewriteRule ^(.*)\.[\d]+\.(css|js)$ $1.$2 [L] It's these 2 lines in each rewrite rule RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
  5. path = / domain = the correct domain. no www. my htaccess redirects everything to non www http_only = no I was able to resolve the issue for the moment by moving a couple files to the root, at least the site works now. This is not ideal and doesn't answer why this happened though. So I still would like any suggestions. I can't find anything wrong with any setting or anything. It worked last night and then didn't this morning. I totally understand that something had to have happened, I just can't find it.
  6. Also there is no htaccess restricting the viewing in the folder I'm trying to put the js file, or any other type of restriction that I know of since I can execute other php code in the file, just not session data.
  7. I'm getting somewhere I think. If I move the js file to the root folder it works. But if I have it at any level above root it won't pick up the session. What would cause that?
  8. You can visit the file in the script tag directly in the browser and there is no output in the file.
  9. I just changed the php version on the server to 7.1 like my local has and that made no difference.
  10. Yes I can load it directly just fine. Here is a link to the test page http://remotelystarted.com/test
  11. Here is a basic test code that I can't even make work. php page: <?php /** * Created by PhpStorm. */ session_start(); $_SESSION['loc_settings'] = 'something'; ?> <!DOCTYPE HTML> <html lang="en"> <head></head> <body> <div id="location-root-map">Map goes here</div> <script src="/site_specific/other_pages/defer-change-vehicle-display.php"></script> </body> </html> Javascript file: <?php error_reporting(E_ALL); session_start(); header("Content-Type: application/javascript"); ?> <?php if(isset($_SESSION['loc_settings'])) { ?> // Inserts the Google Maps iframe after page load $(document).ready(function(){ $('#location-root-map').html('<iframe width="100%" frameborder="0" style="border:0" src="http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=<?php echo $_SESSION['loc_settings']['site_street'],'+',$_SESSION['loc_settings']['site_city'],'+',$_SESSION['loc_settings']['site_state'],'+',$_SESSION['loc_settings']['site_zip'];?>&aq=0&vpsrc=0&ie=UTF8&hq=&hnear=<?php echo $_SESSION['loc_settings']['site_street'],'+',$_SESSION['loc_settings']['site_city'],'+',$_SESSION['loc_settings']['site_state'],'+',$_SESSION['loc_settings']['site_zip'];?>&output=embed"></iframe>' ); }); <?php unset($_SESSION['loc_settings']); } ?> Looking at the output from the js file is empty. Look at it on my local and it has content. Display errors is on, even on the server.
  12. Nope, just standard file based.
  13. I can echo the session_id() from the javascript file and it's the same as the cookie in the developer console, even after refreshing the page a few times. I can echo the session vars right up to the <script> call, so it's not being lost down the page. Doing a dump on the session in the javascript file returns an empty array.
  14. I've got a weird one here. Last night everything was working fine that I know of. This morning my hosted dedicated server will no longer hold session data in a javascript file. Meaning I have a couple javascript files that are .php extensions and inside them it has session_start() at the very top and then it sets the content type accordingly to a js file. I have a couple things in there that output js code based on session data from php. Up until last night this method has been working for a couple of years without any issue. Get up this morning and none of it works. I've gone over the whm changelog but the last update was 5 days ago, not last night. I've checked any settings I could think of in the whm but nothing has fixed the issue. Server is running php 5.6. I run 7.1 on my local machine and all sites are working fine locally. I've verified that the files on the web host are exactly the same as my local files. The part that makes me sure it's a server issue is that it's not working for domains that I haven't touched in a while. It's also not working when using jquery ajax requests even when I'm sending to a php file. So the php file I'm sending to is also not keeping the session data. Again these are files I have not touched in a while. I don't understand what could have gone wrong.
  15. I am in the process of rebuilding my business sites in the Slim3 MVC framework and using Laravel's Eloquent ORM along with several other dependencies (not that it matters for this question). I am getting the basic hang of Eloquent and Models. My old code has lots of full sql queries throughout, most of which I believe I can easily transform into Models and use simple Eloquent processing. But I have a number of complex queries that either I don't have a clue how to construct with models or can't or maybe shouldn't be done with models. Take these 2 queries for example: "SELECT `".BRANDS."`.*, `".PRODUCTS."`.*, `".CATEGORIES."`.*, `".BANNERS."`.`banner_name`, `".BANNERS."`.`banner_tag`, `".BANNERS."`.`banner_image` FROM `".PRODUCTS."` INNER JOIN `".BRANDS."` ON `".BRANDS."`.`id` = `".PRODUCTS."`.`brand_id` INNER JOIN `".CAT_RELATION."` ON `".CAT_RELATION."`.`product_id` = `".PRODUCTS."`.`id` INNER JOIN `".CATEGORIES."` ON `".CATEGORIES."`.`cat_id` = `".CAT_RELATION."`.`category_id` LEFT JOIN `".BANNERS."` ON `".BANNERS."`.`id` = `".PRODUCTS."`.`banner_id` AND `".BANNERS."`.`active` = TRUE WHERE `".PRODUCTS."`.`active`=TRUE ".$where." GROUP BY `".PRODUCTS."`.`id` ORDER BY $order_by" "SELECT `".QUOTE_RESPONSES."`.*, `".QUOTE_ITEMS."`.*, `".PRODUCTS."`.*, `".QUOTE_DEPOSITS."`.`id` AS `deposit_id`, `".QUOTE_DEPOSITS."`.`product_id` AS `deposit_prod`, `".QUOTE_DEP_RESP."`.`id` as `dep_resp_id`, `".QUOTE_REQUESTS."`.`cookie_code`, `".QUOTE_REQUESTS."`.`id` as `orig_quote_id`, ".CONCAT_VEHICLE." AS `vehicle`, `".QUOTE_REQUESTS."`.`vehicle_sufix`, `".QUOTE_REQUESTS."`.`name`, `".SCH."`.`schedule_id`, `".SCH."`.`install_time`, `".SCH."`.`cancelled`, product_videos.video FROM `".QUOTE_RESPONSES."` INNER JOIN `".QUOTE_ITEMS."` ON `".QUOTE_ITEMS."`.`response_id` = `".QUOTE_RESPONSES."`.`id` INNER JOIN `".PRODUCTS."` ON `".PRODUCTS."`.`id` = `".QUOTE_ITEMS."`.`product_id` INNER JOIN `".QUOTE_REQUESTS."` ON `".QUOTE_REQUESTS."`.`id` = `".QUOTE_RESPONSES."`.`request_id` ".VEHICLE_JOIN." LEFT JOIN `".QUOTE_DEPOSITS."` ON `".QUOTE_DEPOSITS."`.`q_id` = `".QUOTE_RESPONSES."`.`id` LEFT JOIN `".QUOTE_DEP_RESP."` ON `".QUOTE_DEP_RESP."`.`deposit_id` = `".QUOTE_DEPOSITS."`.`id` LEFT JOIN `".SCH."` ON `".SCH."`.`deposit_id` = `".QUOTE_DEPOSITS."`.`id` LEFT JOIN product_videos ON product_videos.id = `".QUOTE_RESPONSES."`.`video_id` AND `product_videos`.`active` = TRUE WHERE `".QUOTE_RESPONSES."`.`id`=$id AND `code`= ?" They are big and full of joins and such to minimize query calls and maximize speed with a single query. Now I totally know how to gather all this info in Eloquent by using multiple queries, but that is going to be a lot of queries instead of 1. I guess my question is: Is it worth trying to figure out how to do this with models or should I just use the Eloquent Query Builder similar to this $this->DB->table('vehicle_attributes_relation') ->join('vehicle_attributes', 'vehicle_attributes.v_att_id', '=', 'vehicle_attributes_relation.att_id') ->join('v_year', 'v_year.id', '=', 'vehicle_attributes_relation.year_id') ->join('v_model', 'v_model.id', '=', 'vehicle_attributes_relation.model_id') ->join('v_make', 'v_make.id', '=', 'v_model.v_make_id') ->select('vehicle_attributes.*', 'v_make.v_make', 'v_model.v_model', 'v_year.v_year') ->where('is_private', 0) ->where('vehicle_attributes.v_att_id', $id) ->orderBy('v_make', 'asc') ->orderBy('v_model', 'asc') ->orderBy('v_year', 'asc') ->get() I want this rebuild to be fast and efficient like it is now and I'm willing to give up a slight bit of performance and query calls, but I think the performance would be really hurt trying to do these examples in models. I just don't want to get into the spaghetti of sql code again in this rebuild.

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.