Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 132,605 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 930 people online right now. Registration is fast and FREE... Join Now!




Random Splashs

 
Reply to this topicStart new topic

Random Splashs, please help!

nickwills
post 16 Oct, 2002 - 11:41 AM
Post #1


ive told capty to change this 30k times, but he's a fag

***
Joined: 5 Sep, 2002
Posts: 482


My Contributions


CODE
<?

$splashcount = 3;

$fileprefix = "splash";

$filesuffix = ".html";

$myrandfile = rand(1, $splashcount);

$myfile = ($fileprefix . $myrandfile . $filesuffix);

if (@include ($myfile)) {
@include ($myfile);
} else {
print "<font face=\"Verdana\"><h2> Failure Processing Request </h2> /n/r<BR> <font size=1>Unable to include $myfile. </font>";
}

?>


okay here's the deal. when i use this script, it displays 2 of each page except for the last one. for example: say i have 7 splash pages, it shows splash1.html thru splash6.html with the same source twice, but number 7 would be right and only displayed once. Why is it doing this? i hope yall understand what im saying.when i look at the source of a double page, it looks like:

CODE
<html><body></body></html><html><body></body></html>


so i know its just being duplicated and i can't figure out why. thanks in advance.

-Nick
User is offlineProfile CardPM

Go to the top of the page

skrilla
post 16 Oct, 2002 - 12:35 PM
Post #2


boots.

*****
Joined: 5 Jul, 2002
Posts: 2,848



Dream Kudos: 14
My Contributions


mad.gif argh.........DIC had a PHP error and now i get to retype my post mad.gif

so here goes ::

the problem is right there in your PHP code:

CODE

<?

$splashcount = 3;

$fileprefix = "splash";

$filesuffix = ".html";

$myrandfile = rand(1, $splashcount);

$myfile = ($fileprefix . $myrandfile . $filesuffix);

if (@include ($myfile)) {
@include ($myfile);
} else {
print "<font face=\"Verdana\"><h2> Failure Processing Request </h2> /n/r<BR> <font size=1>Unable to include $myfile. </font>";
}

?>
you use "if(@include ($myfile))" to test if it can, right? well, if it can, it will. so you dont need to do it again in the "then" clause as you have done. ive tested this script that i made based off of your code smile.gif try it out here to see. refresh the page a bunch and it works wink2.gif

here's the code i used:

CODE
<html>
<title>Random Splash Page</title>
<body>
<?

$splashcount = 3;

$fileprefix = "splash";

$filesuffix = ".html";

$myrandfile = rand(1, $splashcount);

$myfile = ($fileprefix . $myrandfile . $filesuffix);

if (@include ($myfile)) {
    return true;
} else {
    print "<font face=\"Verdana\"><h2> Failure Processing Request </h2> /n/r<BR> <font size=1>Unable to include $myfile. </font>";
}

?>
</body>
</html>
you can see the similarities, neh? wink2.gif

the HTML source for my splashes were simply "source1" or "source2" etc. thats it. no HTML markup, nothing smile.gif keeps it simple wink2.gif if you DO need HTML markup (most people will haha) dont include <body> or <html> tags and the like. they will be on the index.php page for you (when you include the file). leave those out and you'll be fine smile.gif

enjoi!

-pete pirate.gif (if you have any questions etc, feel free to email or PM me!)
User is offlineProfile CardPM

Go to the top of the page

nickwills
post 16 Oct, 2002 - 12:56 PM
Post #3


ive told capty to change this 30k times, but he's a fag

***
Joined: 5 Sep, 2002
Posts: 482


My Contributions


thanks a lot skrilla, that did the trick
User is offlineProfile CardPM

Go to the top of the page

LuxFX
post 17 Oct, 2002 - 06:54 AM
Post #4


D.I.C Head

**
Joined: 9 Aug, 2001
Posts: 63

Alternatively, if you simply want to test for the existance of the file, this would work:
CODE
if (file_exists($myfile)) {
@include ($myfile);
} else {
print "<font face=\"Verdana\"><h2> Failure Processing Request </h2> /n/r<BR> <font size=1>Unable to include $myfile. </font>";
}


cheers!
LuxFX
User is offlineProfile CardPM

Go to the top of the page

skrilla
post 17 Oct, 2002 - 12:28 PM
Post #5


boots.

*****
Joined: 5 Jul, 2002
Posts: 2,848



Dream Kudos: 14
My Contributions


QUOTE(nickwills @ Oct 16 2002, 03:56 PM)
thanks a lot skrilla, that did the trick

no problem. anytime, mang wink2.gif
User is offlineProfile CardPM

Go to the top of the page

Dr. Tim
post 17 Oct, 2002 - 12:43 PM
Post #6


D.I.C Addict

****
Joined: 20 Mar, 2002
Posts: 993

<?
/*
Tim Ferrell 2002, FlashAges.com

Your random splashes will start with a delimter of 1. */
/* Your number of splashes below */

$splashcount = 2;

/* File prefix */

$fileprefix = "splash";

/* File suffix */

$filesuffix = ".html";

/* Final example "splash1.html" */

/* DO NOT EDIT BELOW THIS LINE!!! */

/* Get random number */

$myrandfile = rand(1, $splashcount);

$myfile = ($fileprefix . $myrandfile . $filesuffix);

if (@include ($myfile)) {
} else {
print "<font face=\"Verdana\"><h2> Failure Processing Request </h2> <BR> <font size=1>Unable to include $myfile. </font>";
}

/********************/
/*Everything is complete.*/

?>
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/23/08 02:18AM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month