i have a script for sohwing daily quotes on my webpage but something is wrong in the coding and an error message shows up. but the quote still shows up under the error message. help someone!!!!
this is the code for the script:
<?php
$numDB = 1;
$dbFileName = array("quotes.db");
$quoteType = 2;
/*
The variable $quoteType determines the type of quote generation.
quoteType = 0 displays a new random quote each time the page is loaded.
quoteType = 1 displays a new random quote every 60 minutes.
quoteType = 2 displays a new random quote every 24 hours.
quoteType = 3 displays a new random quote once every 7 days.
Settings 1, 2 & 3 are handled by storing a cookie. Use the included "del_cookie.php" script to delete the cookie while you are testing the script.
*/
if ($numDB == 1){
$filename = $dbFileName[0];
}else{
$ranDB = rand(1, $numDB);
$filename = $dbFileName[$ranDB-1];
}
/*
This conditional Statement if ($numDB == 1){.... is picking the database from which to pull the quotes. If the variable $numDB is set to 1 it pulls the first db in the array. You will notice that $dbFileName is set to 0. This is because most languages consider 0 to be the first number when counting.
*/
$lines = file($filename);
$numQuotes = count ($lines);
if ($quoteType == 0){
$ranNum = rand(1, $numQuotes);
} elseif ($quoteType == 1){
if (isset($_COOKIE['quoteNum'])) {
$ranNum = $_COOKIE['quoteNum'];
} else {
$ranNum = rand(1, $numQuotes);
setcookie("quoteNum", $ranNum, time()+60*60);// One Hour
}
}elseif ($quoteType == 2){
if (isset($_COOKIE['quoteNum'])) {
$ranNum = $_COOKIE['quoteNum'];
} else {
$ranNum = rand(1, $numQuotes);
setcookie("quoteNum", $ranNum, time()+60*60*24); //Twenty-four Hours
}
}elseif ($quoteType == 3){
if (isset($_COOKIE['quoteNum'])) {
$ranNum = $_COOKIE['quoteNum'];
} else {
$ranNum = rand(1, $numQuotes);
setcookie("quoteNum", $ranNum, time()+60*60*24*7); // Seven Days
}
}
/*
This conditional Statement if ($quoteType == 0){.... is determining the interval at which you want the quotes displayed. This feature uses the Set Cookie function. Which places a cookie in the users browser.
*/
$line = $lines[$ranNum-1];
$element = explode("|",$line);
$theQuote = $element[0];
$theRef = $element[1];
include ('quote_func.php'); // this references the HTML that will be output to the browser.
// $output = outputLine($theQuote, $theRef);
$output = outputTable($theQuote, $theRef);
echo $output;
?>
this is the error message i get:
Warning: Cannot modify header information - headers already sent by (output started at /home/./domains/dreamer.frih.net/public_html/index.php:7) in /home/./domains/dreamer.frih.net/public_html/quotes.php on line 41[/b]
this is the code for the script:
<?php
$numDB = 1;
$dbFileName = array("quotes.db");
$quoteType = 2;
/*
The variable $quoteType determines the type of quote generation.
quoteType = 0 displays a new random quote each time the page is loaded.
quoteType = 1 displays a new random quote every 60 minutes.
quoteType = 2 displays a new random quote every 24 hours.
quoteType = 3 displays a new random quote once every 7 days.
Settings 1, 2 & 3 are handled by storing a cookie. Use the included "del_cookie.php" script to delete the cookie while you are testing the script.
*/
if ($numDB == 1){
$filename = $dbFileName[0];
}else{
$ranDB = rand(1, $numDB);
$filename = $dbFileName[$ranDB-1];
}
/*
This conditional Statement if ($numDB == 1){.... is picking the database from which to pull the quotes. If the variable $numDB is set to 1 it pulls the first db in the array. You will notice that $dbFileName is set to 0. This is because most languages consider 0 to be the first number when counting.
*/
$lines = file($filename);
$numQuotes = count ($lines);
if ($quoteType == 0){
$ranNum = rand(1, $numQuotes);
} elseif ($quoteType == 1){
if (isset($_COOKIE['quoteNum'])) {
$ranNum = $_COOKIE['quoteNum'];
} else {
$ranNum = rand(1, $numQuotes);
setcookie("quoteNum", $ranNum, time()+60*60);// One Hour
}
}elseif ($quoteType == 2){
if (isset($_COOKIE['quoteNum'])) {
$ranNum = $_COOKIE['quoteNum'];
} else {
$ranNum = rand(1, $numQuotes);
setcookie("quoteNum", $ranNum, time()+60*60*24); //Twenty-four Hours
}
}elseif ($quoteType == 3){
if (isset($_COOKIE['quoteNum'])) {
$ranNum = $_COOKIE['quoteNum'];
} else {
$ranNum = rand(1, $numQuotes);
setcookie("quoteNum", $ranNum, time()+60*60*24*7); // Seven Days
}
}
/*
This conditional Statement if ($quoteType == 0){.... is determining the interval at which you want the quotes displayed. This feature uses the Set Cookie function. Which places a cookie in the users browser.
*/
$line = $lines[$ranNum-1];
$element = explode("|",$line);
$theQuote = $element[0];
$theRef = $element[1];
include ('quote_func.php'); // this references the HTML that will be output to the browser.
// $output = outputLine($theQuote, $theRef);
$output = outputTable($theQuote, $theRef);
echo $output;
?>
this is the error message i get:
Warning: Cannot modify header information - headers already sent by (output started at /home/./domains/dreamer.frih.net/public_html/index.php:7) in /home/./domains/dreamer.frih.net/public_html/quotes.php on line 41[/b]
