Jump to content
Larry Ullman's Book Forums

Michel G.

Members
  • Posts

    7
  • Joined

  • Last visited

Michel G.'s Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Thanks a lot for the reference to the manual, even though I need some time to master expressions like "new DateTime" or "DateInterval". Is this related to OOP? Or in the "QuickPro" guide?...
  2. 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?
  3. 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?...
  4. After having almost finished learning the "Quickstart" version of the book, I recently bought the "Quickpro". I just had a look at the index, and I'm a little bit surprised not to find any mention of CMS as a widespread application of php/mySQL. Can you recommend a book dealing with this topic? Something like "Understand WordPress php/mySQL background"
  5. 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?
  6. Thanks a lot! At this time, the shortest one for my purpose is the following: $year = substr($date,-4); In the future, I'll further consider alternatives.
  7. I would like to retreive the year from a date I enter (and which is not necessarily the date of the day!). For instance, I enter something like "$date = '15-09-2010';" How can I retrieve "2010" from this declaration?
×
×
  • Create New...