Author |
Message |
Donovan
Client

Joined: Oct 07, 2003
Posts: 735
Location: Ohio
|
Posted:
Sun Apr 17, 2005 8:17 pm |
|
Anybody have problems getting the older Random Quotes working in Nuke.
I am running 7.3 and can't get an older version of qotd to work.
The block has this at the top.
Quote: | <?
// qotd (Quote of the day) function for phpnuke, based on
// software originally by Joe Stump of miester.org.
//
// adapted for phpnuke 4.x and 5.x by Erik Sooff (erik@slooff.com)
//
// 22-5-2001
//////////////////////////////////////////////////////////////////////
// 16-08-2001
// Converted to the new PHP-Nuke 5.1 Blocks System by Thiago Campos
// You can contact me at mrhemp@amigoz.org
///////////////////////////////////////////////////////////////////// |
Here is the entire qotd.php page.
Code:<?php
######################################################################
# PHP-NUKE: Web Portal System
# ===========================
#
# Copyright (c) 2000 by Francisco Burzi (fburzi@ncc.org.ve)
# http://phpnuke.org
#
# This module is the main administration part
#
# This program is free software. You can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License.
######################################################################
# PHP-NUKE 5.0 Version by Erik Slooff (erik@slooff.com)
# http://www.slooff.com
######################################################################
# PHP-NUKE 5.1 Blocks Version by Thiago Campos (mrhemp@amigoz.org)
# http://www.amigoz.org
######################################################################
if (!eregi("admin.php", $PHP_SELF)) { die ("Access Denied"); }
global $prefix, $currentlang;
if(file_exists("language/qotd/qotd-$currentlang.php")) {
include("language/qotd/qotd-$currentlang.php");
}
else {
include("language/qotd/qotd-english.php");
}
// only do this stuff if the user is authorised (superadmin)
$result = mysql_query("select radminsuper from $prefix"._authors." where aid='$aid'");
list($radminsuper) = mysql_fetch_row($result);
if ($radminsuper==1) {
// Default function to display the admin stuff for the Quote Add-on
function QotdAdmin() {
global $hlpfile, $admin, $prefix;
include ("config.php");
$hlpfile = "manual/$language/downloads.html";
include ("header.php");
GraphicAdmin($hlpfile);
OpenTable();
echo "</center><font size=4><b>"._ADDQUOTE."</b><br><br>
<font size=2>
<form action=admin.php method=post>
<table border=0 width=100%><tr><td>
"._QUOTETEXT.": </td><td><textarea class=textbox name=qquote cols=60 rows=5></textarea></td></tr><tr><td>
"._AUTHOR.": </td><td><input class=textbox type=text name=qauthor size=31 maxlength=128></td></tr><tr><td>
</td></tr></table>
<input type=hidden name=op value=QotdAdd>
<input type=submit value="._ADD.">
</form><br>
<a href =\"admin.php?op=QotdDisplay&page=1\">" ._MODQUOTES."</a></font><br><br>
</td></tr></table></td></tr></table>";
include("footer.php");
}
// function for adding new quotes
function QotdAdd($qquote, $qauthor) {
global $prefix;
$time = date("Y-m-d");
mysql_query("insert into $prefix"._quotes." (quote, author) values ('$qquote', '$qauthor')");
Header("Location: admin.php?op=QotdAdmin");
}
// function for displaying multiple quotes
function QotdDisplay($page) {
global $hlpfile, $admin, $keyword, $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4, $prefix;
include ("config.php");
$hlpfile = "manual/$language/downloads.html";
include ("header.php");
GraphicAdmin($hlpfile);
OpenTable();
$keyword2 = ereg_replace(" ", "%", $keyword);
$whereclause = "where quote like \"%".$keyword2."%\"";
if ($keyword == "") $whereclause = "";
$result = mysql_query("SELECT COUNT(*) as help FROM $prefix"._quotes." $whereclause");
list($numrecords) = mysql_fetch_row($result);
$entriesperpage = 20;
$totalpages = ceil($numrecords / $entriesperpage);
if ($numrecords > 0) {
echo "</center><font size=4><b>"._MODQUOTES."</b></font><br><br>
<table><tr><td>
<form action=admin.php method=post>
"._SEARCHKEY.": <input class=textbox type=text name=keyword size=31 maxlength=128 value=\"$keyword\">
<input type=hidden name=page value=1>
<input type=hidden name=op value=QotdDisplay>
<input type=submit value="._SEARCH.">
</form></td><td><form action=admin.php method=post>
<input type=hidden name=page value=1>
<input type=hidden name=op value=QotdDisplay>
<input type=submit value=\""._RESETSEARCH."\">
</form></td></tr></table>
<font size=2>
<table border width=\"100%\">";
echo "<tr bgcolor=\"$bgcolor4\"><td ><font size=\"3\">" ._QUOTE."</td><td><font size=\"3\">" ._AUTHOR."</td><td><font size=\"3\">" ._ACTION."</td></tr>";
$start = $entriesperpage * ($page - 1);
$sql = "SELECT qid, quote, author FROM $prefix"._quotes." $whereclause order by qid limit $start, $entriesperpage";
$result = mysql_query($sql);
while(list($qqid, $qquote, $qauthor) = mysql_fetch_array($result)) {
echo "<tr><td bgcolor=\"$bgcolor4\"><font size=\"2\">".substr($qquote,0,50)."</td><td bgcolor=\"$bgcolor4\"><font size=\"2\">".substr($qauthor,0,50)."</td>";
echo "<td bgcolor=\"$bgcolor4\"><font size=\"2\"><a href=\"admin.php?op=QotdEdit&qid=$qqid&page=$page\">" ._EDIT."</a> | <a href=\"admin.php?op=QotdDelete&qid=$qqid&page=$page\">" ._DELETE."</a></td>";
echo "</tr>";
}
echo "</table><br>";
if ($page > 1) {
$prevpage = $page - 1;
} else {
$prevpage = 0;
}
if ($page < $totalpages) {
$nextpage = $page + 1;
} else {
$nextpage = 0;
}
echo "<table border=0 width=\"100%\"><tr><td align=\"center\" width=\"33%\">";
if ($prevpage != 0) {
echo "<a href=\"admin.php?op=QotdDisplay&page=$prevpage&keyword=$keyword\">" ._PREVIOUS."</a>";
} else {
echo " ";
}
echo "</td><td align=\"center\" width=\"33%\">";
echo "<a href=\"admin.php?op=QotdAdmin\">" ._GOBACK2."</a>";
echo "</td><td align=\"center\" width=\"33%\">";
if ($nextpage !=0) {
echo "<a href=\"admin.php?op=QotdDisplay&page=$nextpage&keyword=$keyword\">" ._NEXT."</a>";
} else {
echo " ";
}
echo "</td></tr></table>";
} else {
echo ""._NOQUOTES."";
}
echo "</td></tr></table></td></tr></table>";
include("footer.php");
}
// function for deletion of quotes
function QotdDelete($qid,$page) {
global $hlpfile, $admin, $prefix;
include ("config.php");
$hlpfile = "manual/$language/downloads.html";
include ("header.php");
GraphicAdmin($hlpfile);
OpenTable();
echo "</center><font size=4><b>" ._DELETEQUOTE."</b><br><br>";
echo "<center>";
echo "<font size=3 color=Red>";
echo "<b>"._QUOTEWARNING."</b><br><br><font color=Black>";
echo "[ <a href=admin.php?op=QotdDeleteOk&qid=$qid&page=$page>"._YES."</a> | <a href=admin.php?op=QotdDisplay&page=$page>"._NO."</a> ]<br><br>";
echo "</td></tr></table></td></tr></table>";
include("footer.php");
}
// function for confirmation for deletion of quotes
function QotdDeleteOk($qid,$page) {
global $prefix;
mysql_query("DELETE FROM $prefix"._quotes." where qid='$qid'");
header("Location: admin.php?op=QotdDisplay&page=$page");
}
// function for editing of quotes
function QotdEdit($qid,$page) {
global $hlpfile, $admin, $prefix;
include ("config.php");
$hlpfile = "manual/$language/downloads.html";
include ("header.php");
GraphicAdmin($hlpfile);
$result = mysql_query("SELECT quote, author FROM $prefix"._quotes." WHERE qid = '$qid'");
list($quote,$author) = mysql_fetch_row($result);
OpenTable();
echo "</center><font size=4><b>" ._EDITQUOTE."</b><br><br>
<font size=2>
<form action=admin.php?op=QotdAdmin method=post>
<table border=0 width=100%><tr><td>
" ._QUOTETEXT." </td><td><textarea class=\"textbox\" name=\"qquote\" cols=\"60\" rows=\"5\">$quote</textarea></td></tr><tr><td>
" ._AUTHOR.": </td><td><input class=\"textbox\" type=\"text\" name=\"qauthor\" size=\"31\" maxlength=\"128\" value=\"$author\"></td></tr><tr><td>
</td></tr></table>
<input type=hidden name=op value=QotdSave>
<input type=hidden name=page value=$page>
<input type=hidden name=qqid value=$qid>
<input type=submit value=" ._SAVECHANGES.">
</form>
</td></tr></table></td></tr></table>";
include("footer.php");
}
// function for saving modified quotes
function QotdSave($qqid,$qquote,$qauthor,$page) {
global $prefix;
mysql_query("UPDATE $prefix"._quotes." set quote='$qquote', author='$qauthor' WHERE qid='$qqid'");
Header("Location: admin.php?op=QotdDisplay&page=$page");
}
// These are the various options when we've included this file
switch($op) {
case "QotdAdmin":
QotdAdmin();
break;
case "QotdAdd":
QotdAdd($qquote, $qauthor);
break;
case "QotdSave":
QotdSave($qqid,$qquote,$qauthor,$page);
break;
case "QotdDeleteOk":
QotdDeleteOk($qid,$page);
break;
case "QotdDelete":
QotdDelete($qid,$page);
break;
case "QotdDisplay":
QotdDisplay($page);
break;
case "QotdEdit":
QotdEdit($qid,$page);
break;
}
} else {
// message when user is not authorized
echo "Access Denied";
}
// end of file
?>
|
Any help is appreciated. All I am getting is the "No quotes found" showing in my block. |
|
|
 |
 |
Raven
Site Admin/Owner

Joined: Aug 27, 2002
Posts: 17088
|
Posted:
Sun Apr 17, 2005 11:11 pm |
|
Are there any quotes in the database? This is the admin module that you posted here. But, the block is where the message is. |
|
|
|
 |
Donovan

|
Posted:
Mon Apr 18, 2005 7:42 am |
|
Yes I have about 10 or so quotes there. |
|
|
|
 |
Raven

|
Posted:
Mon Apr 18, 2005 8:49 am |
|
Please post the block code. |
|
|
|
 |
Donovan

|
Posted:
Mon Apr 18, 2005 8:53 am |
|
Code:<?
// qotd (Quote of the day) function for phpnuke, based on
// software originally by Joe Stump of miester.org.
//
// adapted for phpnuke 4.x and 5.x by Erik Sooff (erik@slooff.com)
//
// 22-5-2001
//////////////////////////////////////////////////////////////////////
// 16-08-2001
// Converted to the new PHP-Nuke 5.1 Blocks System by Thiago Campos
// You can contact me at mrhemp@amigoz.org
/////////////////////////////////////////////////////////////////////
global $prefix, $currentlang;
if(file_exists("language/qotd/qotd-$currentlang.php")) {
include("language/qotd/qotd-$currentlang.php");
}
else {
include("language/qotd/qotd-english.php");
}
// initiate some vars
$content = '';
// Create the random id for the quote
$result = mysql_query("SELECT COUNT(*) FROM $prefix"._quotes."");
$quote_count = mysql_fetch_array($result);
$quote_count = $quote_count[0];
// only proceed if we have quotes in the database
if ($quote_count > 0) {
if ($quote_count == 1) {
$random = 0;
} else {
srand((double)microtime()*1000000);
$random = rand(0,$quote_count - 1);
}
// Now that we have the random number we can pull out the record
$result = mysql_query("SELECT * FROM $prefix"._quotes." LIMIT $random,1");
$myrow = mysql_fetch_row($result);
// this is the start of the content for the qotd block
$content = '<center><font class=tiny><i>';
// add the quote text and remove whitespaces at begin or end
$content .= trim($myrow[1]);
$content .= '</i><br>';
// add the author and then close everything
$content .= '-- '.stripslashes($myrow[2]).'</font></center>';
} else {
// this is what we say when the quotes database is empty
$content = ''._NOQUOTES.'';
}
?>
|
|
|
|
|
 |
Raven

|
Posted:
Mon Apr 18, 2005 9:27 am |
|
Change these linesCode: // Create the random id for the quote
$result = mysql_query("SELECT COUNT(*) FROM $prefix"._quotes."");
$quote_count = mysql_fetch_array($result);
$quote_count = $quote_count[0];
| toCode: // Create the random id for the quote
$result = mysql_query("SELECT COUNT(*) FROM $prefix"._quotes."");
$quote_count = mysql_fetch_array($result);
echo 'qc = '.$quote_count.'<br />';
$quote_count = $quote_count[0];
echo 'qc = '.$quote_count.'<br />';
die();
|
and post back the result. This will kill your page after that block. Just remove the lines after you get the initial results. |
|
|
|
 |
Donovan

|
Posted:
Mon Apr 18, 2005 10:09 am |
|
|
|
 |
Raven

|
Posted:
Mon Apr 18, 2005 12:41 pm |
|
Well, that's your problem. $quote_count is empty. Try adding $dbi to the global lineCode:global $prefix, $currentlang, $dbi;
|
and then changeCode:$result = mysql_query("SELECT COUNT(*) FROM $prefix"._quotes."");
| toCode:$result = mysql_query("SELECT COUNT(*) FROM $prefix"._quotes."",$dbi);
|
|
|
|
|
 |
Donovan

|
Posted:
Mon Apr 18, 2005 2:17 pm |
|
Still shows "No quotes found"
Here is what I have so far.
Code:global $prefix, $currentlang, $dbi;
if(file_exists("language/qotd/qotd-$currentlang.php")) {
include("language/qotd/qotd-$currentlang.php");
}
else {
include("language/qotd/qotd-english.php");
}
// initiate some vars
$content = '';
// Create the random id for the quote
$result = mysql_query("SELECT COUNT(*) FROM $prefix"._quotes."",$dbi);
$quote_count = mysql_fetch_array($result);
$quote_count = $quote_count[0];
// only proceed if we have quotes in the database
if ($quote_count > 0) {
if ($quote_count == 1) {
$random = 0;
} else {
srand((double)microtime()*1000000);
$random = rand(0,$quote_count - 1);
}
// Now that we have the random number we can pull out the record
$result = mysql_query("SELECT * FROM $prefix"._quotes." LIMIT $random,1",$dbi);
$myrow = mysql_fetch_row($result);
// this is the start of the content for the qotd block
$content = '<center><font class=tiny><i>';
// add the quote text and remove whitespaces at begin or end
$content .= trim($myrow[1]);
$content .= '</i><br>';
// add the author and then close everything
$content .= '-- '.stripslashes($myrow[2]).'</font></center>';
} else {
// this is what we say when the quotes database is empty
$content = ''._NOQUOTES.'';
}
?>
|
|
|
|
|
 |
Raven

|
Posted:
Mon Apr 18, 2005 4:20 pm |
|
Replace these 2 lines
$quote_count = mysql_fetch_array($result);
$quote_count = $quote_count[0];
with
$quote_count = mysql_num_rows($result); |
|
|
|
 |
Donovan

|
Posted:
Mon Apr 18, 2005 6:26 pm |
|
*sigh* Same results.
"No quotes found"
Here is a dump of the table.
Code:-- Host: localhost
-- Generation Time: Apr 18, 2005 at 07:25 PM
-- Server version: 4.0.24
-- PHP Version: 4.3.11
--
-- Database: `xxxxxxx`
--
-- --------------------------------------------------------
--
-- Table structure for table `nuke_quotes`
--
CREATE TABLE `nuke_quotes` (
`qid` int(10) unsigned NOT NULL auto_increment,
`quote` text,
`author` varchar(150) NOT NULL default '',
PRIMARY KEY (`qid`),
KEY `qid` (`qid`)
) TYPE=MyISAM AUTO_INCREMENT=20 ;
--
-- Dumping data for table `nuke_quotes`
--
INSERT INTO `nuke_quotes` VALUES (1, 'A real leader faces the music, even if he doesn''t like the tune.', 'Anonymous');
INSERT INTO `nuke_quotes` VALUES (2, '"Come on, you sons of bitches-do you want to live forever?" \r\n', 'Gunnery Sergeant Dan Daly, USMC, Belleau Wood, June 1918');
INSERT INTO `nuke_quotes` VALUES (3, '"Casualties many; Percentage of dead not known; Combat efficiency; we \r\nare winning." ', 'Colonel David M. Shoup, USMC, Tarawa, 21 November 1943');
INSERT INTO `nuke_quotes` VALUES (4, '"I want you boys to hurry up and ! whip these Germans so we can get out to \r\nthe Pacific to kick the s* *t out of the purple-pissing Japanese, before \r\nthe Godda**ed MARINES get all the credit!" ', 'Lt General George Patton, US Army 1945');
INSERT INTO `nuke_quotes` VALUES (5, '"Goddam it, you''ll never get the Purple Heart hiding in a foxhole! \r\nFollow me!" ', 'Captain Henry P. "Jim" Crowe, USMC, Guadalcanal, 13 January 1943');
INSERT INTO `nuke_quotes` VALUES (6, '"In the absence of orders, go find something and kill it."', 'Field Marshal Erwin Rommel');
INSERT INTO `nuke_quotes` VALUES (7, '"History does not long entrust the care of freedom to the weak or the timid."', 'General Dwight D. Eisenhower');
INSERT INTO `nuke_quotes` VALUES (8, '"The price of freedom is eternal vigilance."', 'Thomas Jefferson');
INSERT INTO `nuke_quotes` VALUES (9, '"I feel that retired generals should never miss an opportunity to remain \r\nsilent concerning matters for which they are no longer responsible."', 'General H. Norman Schwarzkopf');
INSERT INTO `nuke_quotes` VALUES (10, '"Cry ''Havoc'' and let slip the dogs of War."', 'William Shakespeare ("Julius Caesar")');
INSERT INTO `nuke_quotes` VALUES (11, '"Artillerymen believe the world consist of two types of people; other Artillerymen and targets."', 'Unknown');
|
|
|
|
|
 |
Raven

|
Posted:
Mon Apr 18, 2005 6:48 pm |
|
ChangeCode:global $prefix, $currentlang, $dbi;
if(file_exists("language/qotd/qotd-$currentlang.php")) {
include("language/qotd/qotd-$currentlang.php");
}
else {
include("language/qotd/qotd-english.php");
}
// initiate some vars
$content = '';
// Create the random id for the quote
$result = mysql_query("SELECT COUNT(*) FROM $prefix"._quotes."",$dbi);
|
toCode:global $prefix, $currentlang, $dbi;
$content = '';
if(file_exists("language/qotd/qotd-$currentlang.php")) {
include("language/qotd/qotd-$currentlang.php");
$contents .= '1<br />';
}
else {
include("language/qotd/qotd-english.php");
$contents .= '2<br />';
}
// initiate some vars
// $content = '';
// Create the random id for the quote
$result = mysql_query("SELECT COUNT(*) FROM $prefix"._quotes."",$dbi) or die('MySQL said '.mysql_error());
|
|
|
|
|
 |
Donovan

|
Posted:
Mon Apr 18, 2005 8:08 pm |
|
This is really strange. Now where the block should be says the following
MySQL said Table 'thirdadm_finance.nuke_quotes' doesn't exist
That is where I have my Nuke Treasury. Why is this script pointing to the wrong database? |
|
|
|
 |
Raven

|
Posted:
Mon Apr 18, 2005 8:16 pm |
|
My guess is that your NT script is stepping on the $prefix variable. Is the QOTD block right beneath your Treasury block? |
|
|
|
 |
Donovan

|
Posted:
Mon Apr 18, 2005 8:39 pm |
|
There are 3 blocks in between on the right side. |
|
|
|
 |
Donovan

|
Posted:
Mon Apr 18, 2005 8:40 pm |
|
I moved it to the left side and it came back but it still says "No quotes found"
Thanks for your help in this by the way. |
|
|
|
 |
Raven

|
Posted:
Mon Apr 18, 2005 11:35 pm |
|
Add this line back again:
$result = mysql_query("SELECT COUNT(*) FROM $prefix"._quotes."",$dbi) or die('MySQL said '.mysql_error());
If it still points to the wrong data base, right after the global line add this:
$prefix = 'nuke'; or whatever your $prefix is supposed to be. |
|
|
|
 |
Donovan

|
Posted:
Tue Apr 19, 2005 7:36 am |
|
I never took the first line out. I moved it back to the right side of the page with the $prefix='nuke'; and the error came back
MySQL said Table 'thirdadm_finance.nuke_quotes' doesn't exist
This is bizzare. |
|
|
|
 |
Donovan

|
Posted:
Fri Sep 23, 2005 2:49 pm |
|
Never did get this working. Anybody have another random quotes block to use? |
|
|
|
 |
spasticdonkey
RavenNuke(tm) Development Team

Joined: Dec 02, 2006
Posts: 1693
Location: Texas, USA
|
Posted:
Thu Jan 11, 2007 8:38 pm |
|
Is it just me or do the long quotes appear more often than the shorter ones? |
|
|
|
 |
|