Author |
Message |
gizmo2
Hangin' Around

Joined: Sep 15, 2007
Posts: 34
Location: Germany
|
Posted:
Fri Sep 28, 2007 1:48 pm |
|
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>·</big></strong> <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. |
|
|
|
 |
evaders99
Former Moderator in Good Standing

Joined: Apr 30, 2004
Posts: 3221
|
Posted:
Fri Sep 28, 2007 2:04 pm |
|
You don't need the $content = "" surrounding the numrows line. That is a standard PHP code. |
_________________ - Only registered users can see links on this board! Get registered or login! -
Need help? Only registered users can see links on this board! Get registered or login! |
|
|
 |
gizmo2

|
Posted:
Fri Sep 28, 2007 3:27 pm |
|
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>·</big></strong> <a href=\"modules.php?name=4nAlbum">'._pictures4nAlbum.'</a>: '.$num.'<br />';";
?>
| ?
That doesn't work too... |
|
|
|
 |
spcdata
Regular


Joined: Jan 24, 2004
Posts: 81
Location: Sweden
|
Posted:
Fri Sep 28, 2007 4:33 pm |
|
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>·</big></strong> <a href=\"modules.php?name=4nAlbum\">'._pictures4nAlbum.'</a>: '.$num.'<br />";
?>
|
|
_________________ /spcdata |
|
|
 |
gizmo2

|
Posted:
Sat Sep 29, 2007 12:31 am |
|
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
|
Posted:
Sat Sep 29, 2007 1:31 am |
|
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>·</big></strong> <a href="modules.php?name=4nAlbum">'._pictures4nAlbum.'</a>: '.$num.'<br />';
?>
|
There were some misplaced quotes. |
_________________ Only registered users can see links on this board! Get registered or login!
Only registered users can see links on this board! Get registered or login! |
|
|
 |
gizmo2

|
Posted:
Sat Sep 29, 2007 3:35 am |
|
I would be glad to say it works but it doesn't. |
|
|
|
 |
montego

|
Posted:
Sat Sep 29, 2007 3:45 am |
|
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

|
Posted:
Sat Sep 29, 2007 4:05 am |
|
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>·</big></strong> <a href="modules.php?name=Downloads">'._Downloads.'</a>: '.$num.'<br />';
?>
|
That doesn't work too |
|
|
|
 |
montego

|
Posted:
Sat Sep 29, 2007 4:14 am |
|
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>·</big></strong> <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

|
Posted:
Sat Sep 29, 2007 4:22 am |
|
montego you're my hero!! Thanks a lot for your time. |
|
|
|
 |
gizmo2

|
Posted:
Sat Sep 29, 2007 6:44 am |
|
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>·</big></strong> <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>·</big></strong> <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>·</big></strong> <a href="modules.php?name=Weblinks">'._InteressanteLinks.'</a>: '.$num.'<br />';
$num = $db->sql_numrows($db->sql_query('SELECT * FROM '.$prefix.'_gbook'));
$content = '<strong><big>·</big></strong> <a href="modules.php?name=GbookMX">'._eingetrageneWuensche.'</a>: '.$num.'<br />';
$num = $db->sql_numrows($db->sql_query('SELECT * FROM '.$prefix.'_authors'));
$content = '<strong><big>·</big></strong> <a href="submit.html">'._aktiveautoren.'</a>: '.$num.'<br />';
$num = $db->sql_numrows($db->sql_query('SELECT * FROM '.$prefix.'_stories'));
$content = '<strong><big>·</big></strong> <a href="modules.php?name=News">'._Nachrichten.'</a>: '.$num.'<br />';
?>
|
The block shows only the last entry, the news. What is wrong? |
|
|
|
 |
montego

|
Posted:
Sat Sep 29, 2007 9:39 am |
|
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>·</big></strong> <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>·</big></strong> <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>·</big></strong> <a href="modules.php?name=Weblinks">'._InteressanteLinks.'</a>: '.$num.'<br />';
$num = $db->sql_numrows($db->sql_query('SELECT * FROM '.$prefix.'_gbook'));
$content .= '<strong><big>·</big></strong> <a href="modules.php?name=GbookMX">'._eingetrageneWuensche.'</a>: '.$num.'<br />';
$num = $db->sql_numrows($db->sql_query('SELECT * FROM '.$prefix.'_authors'));
$content .= '<strong><big>·</big></strong> <a href="submit.html">'._aktiveautoren.'</a>: '.$num.'<br />';
$num = $db->sql_numrows($db->sql_query('SELECT * FROM '.$prefix.'_stories'));
$content .= '<strong><big>·</big></strong> <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

|
Posted:
Sat Sep 29, 2007 10:28 am |
|
Once again, you're my hero!!! |
|
|
|
 |
montego

|
Posted:
Mon Oct 01, 2007 6:22 am |
|
nope. This is your hero:
 |
|
|
|
 |
fkelly
Former Moderator in Good Standing

Joined: Aug 30, 2005
Posts: 3312
Location: near Albany NY
|
Posted:
Mon Oct 01, 2007 8:11 am |
|
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>·</big></strong> <a href="modules.php?name=4nAlbum">'._Bilder4nAlbum.'</a>: '.$num.'<br />';
|
You could have:
Code:$content = '<strong><big>·</big></strong> <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. |
|
|
|
 |
|