Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Blocks
Author Message
gizmo2
Hangin' Around



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

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

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

You don't need the $content = "" surrounding the numrows line. That is a standard PHP code.

_________________
- Star Wars Rebellion Network -

Need help? Nuke Patched Core, Coding Services, Webmaster Services 
View user's profile Send private message Visit poster's website
gizmo2







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

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...
 
spcdata
Regular
Regular



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

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

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 />";
?>

_________________
/spcdata 
View user's profile Send private message Send e-mail Visit poster's website
gizmo2







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

Thanks for helping but that doesn't work too. Is there anything special with blocks when i use Ravennuke?
 
montego
Site Admin



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

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

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.

_________________
Where Do YOU Stand?
HTML Newsletter::ShortLinks::Mailer::Downloads and more... 
View user's profile Send private message Visit poster's website
gizmo2







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

I would be glad to say it works but it doesn't.
 
montego







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

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).
 
gizmo2







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

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
 
montego







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

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.
 
gizmo2







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

montego you're my hero!! Thanks a lot for your time.
 
gizmo2







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

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?
 
montego







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

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.
 
gizmo2







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

Once again, you're my hero!!!
 
montego







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

nope. This is your hero:

RavensScripts

Wink
 
fkelly
Former Moderator in Good Standing



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

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

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    Ravens PHP Scripts And Web Hosting Forum Index -> Blocks

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
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©