|Get best price on Prepaid Samsung Galaxy A01|
PHP Script: Quote of the Day
This free PHP script for "Quote of the Day" automatically updates your web site with randomly selected content. It this case, the content is a quote. You can
easily vary the content for your own needs.
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.
A BIG shoutout to trishah.com for finding a error in the following and letting me know. I fixed it. Apologies to anyone I caused to go crazy getting it to work. (Updated January 24, 2018)
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
The web page where you display the quote contains the PHP code that opens, reads and inserts the contents of the quoteToday.txt file.
// display quote of the day
$file = "quoteToday.txt";
$fh = fopen($file, "r");
$string = fread($fh, filesize($file));
Name the file whatever you want.
File the Cron Job Runs (quoteGenerate.php)
Here is the quoteGenerate.php file to download. Save the file with a "PHP" extension. Modify the text in any text editor. Upload the file to your web server and set up your cron job. The internet and your hosting provider have lots of help for setting up cron jobs. You can even start with wikipedia.
Fixing Common Problems
Upload all 4 files to your web server.
Thanks for visiting and I hope you find this helpful. I have used this code of a number of sites.
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)