|Get best price on Samsung Galaxy S5, Copper Gold 16GB (Verizon Wireless)|
PHP Script: Quote of the Day
This free PHP script for "Quote of the Day" automatically updates your web site with a randomly selected quote.
It is easy to set up and customize, and does not require a MySQL database. This tutorial explains how
it is programmed and provides download for all source code.
Tutorial for Quote of the Day PHP Script
My first thought was to use PHP and MySQL. A PHP date function would key off the current date and select the same
quote throughout the day. The next day, it would randomly select a new quote. I thought about using MySQL to store the quotes
and author data and use PHP to dynamically display the day's quote.
Source Code Files for Quote of the Day PHP Script
There are 4 files for "Quote of the Day"
Data File With the Quotes (quoteData.txt)
The file that contains all the quotes is a simple text file. One line for each quote and related data such as author.. The file
can include HTML tags for formatting if you wish. Just be sure each line (that is, each quote) has the formatting you want.
Current Day's Quote (quoteToday.txt)This file contains only one quote, the quote displayed that day. This file is updated daily by your server. Create the file and make it writable. Change permissions (CHMOD) to "646" so the server can save the changes. (646 permissions look like
Here is sample quoteToday.txt file (today's quote) to work with. The file has one line, the content that is displayed that day.
Web Page That Displays the Quote
Your web page where you display the quote contains the PHP code that opens, reads and inserts the contents of the days quote.
// display quote of the day
$file = "todaysQuote.txt";
$fh = fopen($file, "r");
$string = fread($fh, filesize($file));
Name the file whatever you want.
File the Cron Job Runs (quoteGenerate.php)
Fixing Common Problems
Upload all 4 files to your web server.
Test Google Ads Ver. 2
Free Linux Admin Books
Free Linux Books for Programmers
Free Books for Linux on the Desktop
Free PHP Books
Free Java Books - Advanced
Free Java Books - Basic
Free Perl Books
Free Python Books
Quote of the Day (PHP)
Debugging Part 2
How to Test Google Ads
Most Popular Pages
Baby Name Generator
U.S. Name Generator
Wu Name Generator
Upload and Resize an Image (PHP)
How To Install Apache + PHP + MySQL
Intro to Web Databases (PHP, MySQL)
Least Popular Pages
iNews Applet (Java)
Site Monitor (Perl)