PHP Web Host - Quality Web Hosting For All PHP Applications Sign up for PayPal and start accepting credit card payments instantly
  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
dezina
Theme Guru


Joined: Dec 26, 2002
Posts: 57
Location: UK

PostPosted: Wed Jan 14, 2004 8:23 am Reply with quote Back to top

Code:
<?php
if (eregi("block-Pages.php",$PHP_SELF)) {
    Header("Location: index.php");
    die();
}

function directory($result)
     {
     $handle=opendir("./users");
     while ($file = readdir($handle)) {
     if ($file == "." || $file == ".." || $file== "_notes" || $file== "htmlarea" || $file== "index.php") { } else { print "<a href=users/$file>$file</a><br>\n"; }
     }
     closedir($handle);

return $result;
}
$content .= "Select the users home page:";
echo directory($result);
?>


Works, but the result is shown above Block Title, not in actual Block.
Any advice or help gratefully received . TIA
View user's profile Send private message Visit poster's website
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 16987
Location: Kansas

PostPosted: Wed Jan 14, 2004 9:26 am Reply with quote Back to top

You can't echo in a block. All output of a block must be handled through the $content variable. Try something like $content .= directory($result);

I also notice that you are passing a value ($result) to the function but their is nor $result in the block code outside of the function. Could just be that you don't have all the code. Just an observation Smile
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
dezina
Theme Guru


Joined: Dec 26, 2002
Posts: 57
Location: UK

PostPosted: Wed Jan 14, 2004 9:48 am Reply with quote Back to top

Thanks Raven, I've obviously not coded correctly.Am trying to list folders that reside in a directory on server, and the blocks gives links to those folder. When clicked, the user should be taken to index.html file in each of the folders, depending on which link clicked. Any advice here on how I go about this please? TIA
View user's profile Send private message Visit poster's website
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 16987
Location: Kansas

PostPosted: Wed Jan 14, 2004 10:03 am Reply with quote Back to top

I haven't tested this, but you might try
Code:
<?php
if (eregi("block-Pages.php",$PHP_SELF)) {
    Header("Location: index.php");
    die();
}

function directory()
     {
     global $content;
     $handle=opendir("./users");
     while ($file = readdir($handle)) {
     if ($file == "." || $file == ".." || $file== "_notes" || $file== "htmlarea" || $file== "index.php") { } else { $content .= "<a href=users/$file>$file</a><br>\n"; }
     }
     closedir($handle);
}
$content = "Select the users home page:<br />".$content;
?>
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
dezina
Theme Guru


Joined: Dec 26, 2002
Posts: 57
Location: UK

PostPosted: Wed Jan 14, 2004 11:28 am Reply with quote Back to top

Raven, regret no joy, but thank you very much for trying. Wink
View user's profile Send private message Visit poster's website
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 16987
Location: Kansas

PostPosted: Wed Jan 14, 2004 11:37 am Reply with quote Back to top

Are you sure the fucntion is working correctly? Try inserting
echo $content;
after the closedir($handle); statement and see if it prints anything above the block. If not, then the function is not working.
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
dezina
Theme Guru


Joined: Dec 26, 2002
Posts: 57
Location: UK

PostPosted: Wed Jan 14, 2004 11:56 am Reply with quote Back to top

My original coding produces the desired result, BUT it prints the link/s ABOVE the Block title, and not in the actual block, so am assuming that function code is working correctly, just that my code is putting it outside the actual block Confused
View user's profile Send private message Visit poster's website
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 16987
Location: Kansas

PostPosted: Wed Jan 14, 2004 12:50 pm Reply with quote Back to top

But, I need you to try what I suggested to help me in debugging it. Thanks.
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
dezina
Theme Guru


Joined: Dec 26, 2002
Posts: 57
Location: UK

PostPosted: Thu Jan 15, 2004 4:17 am Reply with quote Back to top

Understood.
Code:
<?php
if (eregi("block-Pages.php",$PHP_SELF)) {
    Header("Location: index.php");
    die();
}

function directory($result)
     {
     $handle=opendir("./users");
     while ($file = readdir($handle)) {
     if ($file == "." || $file == ".." || $file== "_notes" || $file== "htmlarea" || $file== "index.php") { } else { print "<a href=users/$file>$file</a><br>\n"; }
     }
     closedir($handle);
echo $content;
return $result;
}
$content .= "Select the users home page:";
$content .= directory($result);
?>


Produces...
Link
Link
Then: Block Title(PAGES)
Then: Select the users home page:
View user's profile Send private message Visit poster's website
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 16987
Location: Kansas

PostPosted: Thu Jan 15, 2004 4:50 am Reply with quote Back to top

First, a question. Did you use the global $content statment in my code I told you to try up above?
Code:
<?php
if (eregi("block-Pages.php",$PHP_SELF)) {
    Header("Location: index.php");
    die();
}

function directory()
     {
     global $content;
     $handle=opendir("./users");
     while ($file = readdir($handle)) {
     if ($file == "." || $file == ".." || $file== "_notes" || $file== "htmlarea" || $file== "index.php") { } else { $content .= "<a href=users/$file>$file</a><br>\n"; }
     }
     closedir($handle);
}
$content = "Select the users home page:<br />".$content;
?>


If that doesn't work, then this should
Code:
<?php
if (eregi("block-Pages.php",$PHP_SELF)) {
    Header("Location: index.php");
    die();
}

function directory($result)
     {
     $content = "";
     $handle=opendir("./users");
     while ($file = readdir($handle)) {
     if ($file == "." || $file == ".." || $file== "_notes" || $file== "htmlarea" || $file== "index.php") { } else { $content .=  "<a href=\"users/$file\">$file</a><br>\n"; }
     }
     closedir($handle);
return $content;
}
$content .= "Select the users home page:<br />";
$content .= directory($result);
?>
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
dezina
Theme Guru


Joined: Dec 26, 2002
Posts: 57
Location: UK

PostPosted: Thu Jan 15, 2004 4:58 am Reply with quote Back to top

Very Happy Thank you so much Raven, Second Version works just fine
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