DeveloperTutorials.com has two new PHP-related items posted today - a look at database connections and getting the difference between two dates.
From Programmatically Deciding Which Database to Connect in PHP:
Most of the time, while working with PHP and MySQL, we have to switch between the local PC and the remote server. After writing and debugging the code on my local machine, I would change the values and upload the files to my client’s server. Then I changed the connect_database() (to add a check for the $_SERVER['HTTP_HOST']).
From Calculating Difference Between Two Dates Using PHP:
Suppose you want to know the age of a person given her birth date. Let’s say her birth date is "09-23-1969". Although in this case you might say that we don’t need a program to compute the age, but assuming there are 1000s of records in your database. ou need to know for how many days a person has been using your website and when the subscription is due. So in this tip we learn to write a function that returns us the number of days elapsed between two dates.
In each one, they give the code you'll need to make these simple additions to any page. They're nothing overly difficult, but users new to the language or looking for a specific solution might find them useful...




