Jump to content
Larry Ullman's Book Forums

Michel G.

Members
  • Posts

    7
  • Joined

  • Last visited

Posts posted by Michel G.

  1. I'm having the following issue to build-up a liturgical calendar; the mistake is related to the daylight saving time, which adds 1h and makes my whole construction invalid:

    <?php
    	$date = strtotime('09-05-2013');
    	echo "Date: ".$date."<br />";
    	// May 9th, 2013 is the effective date of Ascension
    
    	//The year can be easily extracted from the date
    	$year = date('Y', $date);
    	echo "Year: ".$year."<br />";
    
    	// The date of Easter can be easily extracted thanks to the corresponding php-native "easter_date" function
    	$easter = easter_date($year);
    
    	// The ascension is 39 days after Easter
    	$ascension = ($easter + (39*86400));
    	echo "Ascension: ".$ascension."<br />";
    
    	if ($date == $ascension) {
    		echo "It's Ascension";
    	} else {
    		echo "There is a mistake in the code"; }
    ?>
    

     

    The problem is: the date of 09-05-2013 gives a string which is 3600 sec. more than the calculated value based on Easter.
    What can I do to define correctly the $ascension value from Easter, knowing that the daylight saving change does not always occur every year between Easter and Ascension?

     

  2. I was posting a question on this forum when I found the fix to my problem! Now, I propose to share it with our community.

     

    Let's say that I have 2 php pages on my web site:

    • page1.php
    • page2.php

    On page1.php, I make a link to page2.php through the $_GET method:

    localhost:8888/page2.php?id=6&name=tintin
    

    When I try to access page2.php through this link, Safari tells me that opening the page is impossible.

    I get the same error message when I reload it.

     

    If I copy this link and I paste it again in the url box of Safari, the page opens normally and the $_GET values are captured normally as well. I found it crazy as the same url appears in Safari.

     

    I found the explanation thanks to Firefox: when I copy the url and paste it, Firefox adds the prefix http://:

    http://localhost:8888/page2.php?id=6&name=tintin

    And that makes all the difference!

     

    Of course, the fix is now easy: instead of defining the link as "localhost...", simply define it as "http://localhost..."

     

    Not less surprising is the Chrome behavior, which simply does not accept the link "localhost" without the prefix http://.

     

    I wonder whether this issue is described somewhere in the book?...

     

  3. I'm very surprised: I recently received php code written on a PC with a link containing backslash:

    <?php 
    	include_once('include\dbConnect.php');
    ?>
    (...)
    

    This code didn't work (the table content was not displayed). Once I replaced the backslash with slash, the code worked again well.

     

    Maybe obvious for most of you, but it is something I had never heard about!

     

    Now, I wonder what the "slashed" code would give on a PC?

×
×
  • Create New...