PHP Web Host - Quality Web Hosting For All PHP Applications Clan Themes! We make clans look good!!
  Login or Register
 • Home • Downloads • Your Account • Forums • 

View next topic
View previous topic


Google
 
Web RavenPHPScripts (This Site)
Post new topic   Reply to topic
Author Message
gizmo2
Hangin' Around


Joined: Sep 15, 2007
Posts: 34
Location: Germany

PostPosted: Fri Sep 28, 2007 1:48 pm Reply with quote Back to top

Hi everyone I've got a problem with a statistic block.

After a 1 1/2 year break with Nuke i've forgotten nearly everything.

I'm trying to create an statistic block with eg. the ammount of pictures or the ammount of postings in the guestbook.

I've tried it this way:

Code:
<?php
if (eregi("block-Block_Creator.php",$PHP_SELF)) {
    Header("Location: index.php");
    die();
}
$content  =  "$num = $db->sql_numrows($db->sql_query('SELECT * FROM '.$prefix.'_4nalbum_pictures'));";
$content .= "<strong><big>&middot;</big></strong>&nbsp;<a href=\"modules.php?name=4nAlbum">'._pictures4nAlbum.'</a>: '.$num.'<br />';";
?>


I think there are a few mistakes. Can anybody tell me how i need to change the script to get the block work?

Thanks a lot

P.S.: Please excuse my bad english, i use it way to less.
View user's profile Send private message
evaders99
Former Moderator in Good Standing


Joined: Apr 30, 2004
Posts: 3221

PostPosted: Fri Sep 28, 2007 2:04 pm Reply with quote Back to top

You don't need the $content = "" surrounding the numrows line. That is a standard PHP code.
View user's profile Send private message Visit poster's website
gizmo2
Hangin' Around


Joined: Sep 15, 2007
Posts: 34
Location: Germany

PostPosted: Fri Sep 28, 2007 3:27 pm Reply with quote Back to top

Thanks evaders99 for your help.
You mean:
Code:
<?php
if (eregi("block-test.php",$PHP_SELF)) {
    Header("Location: index.php");
    die();
}
$num = $db->sql_numrows($db->sql_query('SELECT * FROM '.$prefix.'_4nalbum_pictures'));;
$content .= "<strong><big>&middot;</big></strong>&nbsp;<a href=\"modules.php?name=4nAlbum">'._pictures4nAlbum.'</a>: '.$num.'<br />';";
?>
?
That doesn't work too...
View user's profile Send private message
spcdata
Regular
Regular


Joined: Jan 24, 2004
Posts: 81
Location: Sweden

PostPosted: Fri Sep 28, 2007 4:33 pm Reply with quote Back to top

try this:

Code:
<?php
if (eregi("block-test.php",$PHP_SELF)) {
    Header("Location: index.php");
    die();
}
$num = $db->sql_numrows($db->sql_query('SELECT * FROM '.$prefix.'_4nalbum_pictures'));
$content .= "<strong><big>&middot;</big></strong>&nbsp;<a href=\"modules.php?name=4nAlbum\">'._pictures4nAlbum.'</a>: '.$num.'<br />";
?>
View user's profile Send private message Send e-mail Visit poster's website
gizmo2
Hangin' Around


Joined: Sep 15, 2007
Posts: 34
Location: Germany

PostPosted: Sat Sep 29, 2007 12:31 am Reply with quote Back to top

Thanks for helping but that doesn't work too. Is there anything special with blocks when i use Ravennuke?
View user's profile Send private message
montego
Site Admin


Joined: Aug 29, 2004
Posts: 9136
Location: Arizona

PostPosted: Sat Sep 29, 2007 1:31 am Reply with quote Back to top

How about a third try:

Code:

<?php
if (eregi('block-test.php',$PHP_SELF)) {
    Header('Location: index.php');
    die();
}
$num = $db->sql_numrows($db->sql_query('SELECT * FROM '.$prefix.'_4nalbum_pictures'));
$content .= '<strong><big>&middot;</big></strong>&nbsp;<a href="modules.php?name=4nAlbum">'._pictures4nAlbum.'</a>: '.$num.'<br />';
?>


There were some misplaced quotes.
View user's profile Send private message Visit poster's website
gizmo2
Hangin' Around


Joined: Sep 15, 2007
Posts: 34
Location: Germany

PostPosted: Sat Sep 29, 2007 3:35 am Reply with quote Back to top

I would be glad to say it works but it doesn't.
View user's profile Send private message
montego
Site Admin


Joined: Aug 29, 2004
Posts: 9136
Location: Arizona

PostPosted: Sat Sep 29, 2007 3:45 am Reply with quote Back to top

Please be more specific. What are the symptoms? Are you sure the SQL is right?

By the way, get rid of the "." in front of the "="... but, that should be causing you an issue I don't think.

There is nothing wrong with the code that I can see (syntactically).
View user's profile Send private message Visit poster's website
gizmo2
Hangin' Around


Joined: Sep 15, 2007
Posts: 34
Location: Germany

PostPosted: Sat Sep 29, 2007 4:05 am Reply with quote Back to top

When I place the block on the left side I got a blank page. The SQL is ok, I changed the code for more transparency to

Code:
<?php
if (eregi('block-Test.php',$PHP_SELF)) {
    Header('Location: index.php');
    die();
}
$num = $db->sql_numrows($db->sql_query('SELECT * FROM '.$prefix.'_downloads_downloads'));
$content = '<strong><big>&middot;</big></strong>&nbsp;<a href="modules.php?name=Downloads">'._Downloads.'</a>: '.$num.'<br />';
?>


That doesn't work too
View user's profile Send private message
montego
Site Admin


Joined: Aug 29, 2004
Posts: 9136
Location: Arizona

PostPosted: Sat Sep 29, 2007 4:14 am Reply with quote Back to top

Sorry, brain hurts from being up all night. Try this:

Code:

<?php
if ( !defined('BLOCK_FILE') ) {
   Header('Location: ../index.php');
   die();
}
global $db, $prefix;
$num = $db->sql_numrows($db->sql_query('SELECT * FROM '.$prefix.'_downloads_downloads'));
$content = '<strong><big>&middot;</big></strong>&nbsp;<a href="modules.php?name=Downloads">'._DOWNLOADS.'</a>: '.$num.'<br />';
?>


There were some globals missing. Also, you may have to change the _DOWNLOADS to something else if you do not have that in your language file.

Regards and good night.
View user's profile Send private message Visit poster's website
gizmo2
Hangin' Around


Joined: Sep 15, 2007
Posts: 34
Location: Germany

PostPosted: Sat Sep 29, 2007 4:22 am Reply with quote Back to top

montego you're my hero!! Thanks a lot for your time.
View user's profile Send private message
gizmo2
Hangin' Around


Joined: Sep 15, 2007
Posts: 34
Location: Germany

PostPosted: Sat Sep 29, 2007 6:44 am Reply with quote Back to top

I'm sorry, I've got one more question.

The actual code is:

Code:
<?php
if ( !defined('BLOCK_FILE') ) {
   Header('Location: ../index.php');
   die();
}
global $db, $prefix;
define('_Bilder4nAlbum','Bilder im Bilderalbum:');
define('_Categorien4nAlbum','Bilderalbum-Kategorien:');
define('_InteressanteLinks','Eingetragene Links:');
define('_eingetrageneWuensche','Eingetragene Wünsche:');
define('_aktiveautoren','Aktive Autoren:');
define('__Nachrichten','Nachrichten:');
$num = $db->sql_numrows($db->sql_query('SELECT * FROM '.$prefix.'_4nalbum_pictures'));
$content = '<strong><big>&middot;</big></strong>&nbsp;<a href="modules.php?name=4nAlbum">'._Bilder4nAlbum.'</a>: '.$num.'<br />';
$num = $db->sql_numrows($db->sql_query('SELECT * FROM '.$prefix.'_4nalbum_categories'));
$content = '<strong><big>&middot;</big></strong>&nbsp;<a href="modules.php?name=4nAlbum">'._Categorien4nAlbum.'</a>: '.$num.'<br />';
$num = $db->sql_numrows($db->sql_query('SELECT * FROM '.$prefix.'_links_links'));
$content = '<strong><big>&middot;</big></strong>&nbsp;<a href="modules.php?name=Weblinks">'._InteressanteLinks.'</a>: '.$num.'<br />';
$num = $db->sql_numrows($db->sql_query('SELECT * FROM '.$prefix.'_gbook'));
$content = '<strong><big>&middot;</big></strong>&nbsp;<a href="modules.php?name=GbookMX">'._eingetrageneWuensche.'</a>: '.$num.'<br />';
$num = $db->sql_numrows($db->sql_query('SELECT * FROM '.$prefix.'_authors'));
$content = '<strong><big>&middot;</big></strong>&nbsp;<a href="submit.html">'._aktiveautoren.'</a>: '.$num.'<br />';
$num = $db->sql_numrows($db->sql_query('SELECT * FROM '.$prefix.'_stories'));
$content = '<strong><big>&middot;</big></strong>&nbsp;<a href="modules.php?name=News">'._Nachrichten.'</a>: '.$num.'<br />';
?>


The block shows only the last entry, the news. What is wrong?
View user's profile Send private message
montego
Site Admin


Joined: Aug 29, 2004
Posts: 9136
Location: Arizona

PostPosted: Sat Sep 29, 2007 9:39 am Reply with quote Back to top

The first "$content = " is right, but the subsequent ones must be "$content .= ". So, the completed code would be:

Code:

<?php
if ( !defined('BLOCK_FILE') ) {
   Header('Location: ../index.php');
   die();
}
global $db, $prefix;
define('_Bilder4nAlbum','Bilder im Bilderalbum:');
define('_Categorien4nAlbum','Bilderalbum-Kategorien:');
define('_InteressanteLinks','Eingetragene Links:');
define('_eingetrageneWuensche','Eingetragene Wünsche:');
define('_aktiveautoren','Aktive Autoren:');
define('__Nachrichten','Nachrichten:');
$num = $db->sql_numrows($db->sql_query('SELECT * FROM '.$prefix.'_4nalbum_pictures'));
$content = '<strong><big>&middot;</big></strong>&nbsp;<a href="modules.php?name=4nAlbum">'._Bilder4nAlbum.'</a>: '.$num.'<br />';
$num = $db->sql_numrows($db->sql_query('SELECT * FROM '.$prefix.'_4nalbum_categories'));
$content .= '<strong><big>&middot;</big></strong>&nbsp;<a href="modules.php?name=4nAlbum">'._Categorien4nAlbum.'</a>: '.$num.'<br />';
$num = $db->sql_numrows($db->sql_query('SELECT * FROM '.$prefix.'_links_links'));
$content .= '<strong><big>&middot;</big></strong>&nbsp;<a href="modules.php?name=Weblinks">'._InteressanteLinks.'</a>: '.$num.'<br />';
$num = $db->sql_numrows($db->sql_query('SELECT * FROM '.$prefix.'_gbook'));
$content .= '<strong><big>&middot;</big></strong>&nbsp;<a href="modules.php?name=GbookMX">'._eingetrageneWuensche.'</a>: '.$num.'<br />';
$num = $db->sql_numrows($db->sql_query('SELECT * FROM '.$prefix.'_authors'));
$content .= '<strong><big>&middot;</big></strong>&nbsp;<a href="submit.html">'._aktiveautoren.'</a>: '.$num.'<br />';
$num = $db->sql_numrows($db->sql_query('SELECT * FROM '.$prefix.'_stories'));
$content .= '<strong><big>&middot;</big></strong>&nbsp;<a href="modules.php?name=News">'._Nachrichten.'</a>: '.$num.'<br />';
?>


The first one sets the variable to the string and then the following ones much ADD to that string, rather than just resetting it each time.
View user's profile Send private message Visit poster's website
gizmo2
Hangin' Around


Joined: Sep 15, 2007
Posts: 34
Location: Germany

PostPosted: Sat Sep 29, 2007 10:28 am Reply with quote Back to top

Once again, you're my hero!!!
View user's profile Send private message
montego
Site Admin


Joined: Aug 29, 2004
Posts: 9136
Location: Arizona

PostPosted: Mon Oct 01, 2007 6:22 am Reply with quote Back to top

nope. This is your hero:

RavensScripts

Wink
View user's profile Send private message Visit poster's website
fkelly
Moderator


Joined: Aug 30, 2005
Posts: 3186
Location: near Albany NY

PostPosted: Mon Oct 01, 2007 8:11 am Reply with quote Back to top

Yeah M! I can't help myself from jumping in even though this has been resolved. Where you have:

Code:
$num = $db->sql_numrows($db->sql_query('SELECT * FROM '.$prefix.'_4nalbum_pictures'));
$content = '<strong><big>&middot;</big></strong>&nbsp;<a href="modules.php?name=4nAlbum">'._Bilder4nAlbum.'</a>: '.$num.'<br />';


You could have:

Code:
$content = '<strong><big>&middot;</big></strong>&nbsp;<a href="modules.php?name=4nAlbum">'._Bilder4nAlbum.'</a> : ' .$db->sql_numrows($db->sql_query('SELECT * FROM '.$prefix.'_4nalbum_pictures')).'<br />';


In other words you can just execute the numrows sql right inside the variable assignment and save a WHOLE DARNED variable. LOL, I know it helps conceptually to simplify things the way you have it but you might want to keep this principal in mind. PHPNUKE is littered with many unnecessary variable assignments like this, some of which we are gradually getting rid of as we work thru Ravennuke. It can be a land mine to deal with because you have to make sure that the "unnecessary" variable is not used anywhere else. And that's why I mention this, it's much better for the original author to keep assignments to a minimum.
View user's profile Send private message Visit poster's website
Display posts from previous:       
Post new topic   Reply to topic

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Forums ©
 

All logos and trademarks in this site are property of their respective owner.
The comments are property of their posters, all the rest © 2002-2011 by Raven

You can syndicate our news using the file xml

CSE HTML Validator Helped Clean up This Page! [Valid RSS] valid RSS 2.0 Valid robots.txt Stop Spam Harvesters, Join Project Honey Pot

Website engines core code is © copyright by PHP-Nuke but has been heavily patched and modified by myself and others.
PHP-Nuke is a free software released under the GNU/GPL.


:: fisubice phpbb2 style by Daz :: PHP-Nuke theme by www.nukemods.com ::
:: fisubice Theme Modified by the RavenNuke™ Team ::

:: W3C CSS Compliance Validation :: W3C HTML 4.01 Transitional Compliance Validation ::

zerosum