![]() |
![]() |
![]() |
||||
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 |
So Fucking Banned
Industry Role:
Join Date: Apr 2003
Location: online
Posts: 8,766
|
php redirect shows blank page
hey, i setup some php rotation redirect...It should redirects people to some url from list.
however i see now, that it returns blank page every now and then...and i had to refresh page to get redirection...why is that ? |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 |
Confirmed User
Industry Role:
Join Date: Jan 2003
Location: Los Angeles
Posts: 736
|
thats kind of like saying that your car doesnt work whats wrong with it, without giving the specifics
__________________
Tanguy 0x7a69 inc. Programmer/President/CEO http://www.0x7a69.com A Leader in Programming since 1996 PHP, Ruby on Rails, MySQL, PCI DSS, and any Technical Consulting |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#3 |
So Fucking Banned
Industry Role:
Join Date: Apr 2003
Location: online
Posts: 8,766
|
<?php
$urls[] = "url1"; $urls[] = "url2"; $urls[] = "url3"; $urls[] = "url4"; $urls[] = "url5"; srand ((double) microtime( )*1000000); $random = rand(0,count($urls)); header("location:" . $urls[$random]); exit; ?> it sometimes redirects&rotate url,sometimes just show blank page.... |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#4 |
Confirmed User
Industry Role:
Join Date: Dec 2002
Location: Behind the scenes
Posts: 5,190
|
perhaps count($urls) needs -1
count($urls)-1
__________________
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#5 |
Confirmed User
Industry Role:
Join Date: Dec 2002
Location: Behind the scenes
Posts: 5,190
|
when debugging you can print out url and random number vars and see where problem lays
![]()
__________________
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#6 |
Confirmed User
Industry Role:
Join Date: Jan 2003
Location: Los Angeles
Posts: 736
|
yea thats what it is you need count($urls)-1 because count returns the number of elements in teh array but the array is indexed starting at 0
__________________
Tanguy 0x7a69 inc. Programmer/President/CEO http://www.0x7a69.com A Leader in Programming since 1996 PHP, Ruby on Rails, MySQL, PCI DSS, and any Technical Consulting |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#7 |
So Fucking Banned
Industry Role:
Join Date: Apr 2003
Location: online
Posts: 8,766
|
so i should add this line somewhere :-P ???
count($urls)-1 ?? where ;-) ? edit: ups now i see it... THANKS !!! ![]() |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#8 |
Confirmed User
Industry Role:
Join Date: Jan 2003
Location: Los Angeles
Posts: 736
|
actually i take that back, dont do the $count-1
instead cahnge this line to this header("location:" . $urls[$random-1]);
__________________
Tanguy 0x7a69 inc. Programmer/President/CEO http://www.0x7a69.com A Leader in Programming since 1996 PHP, Ruby on Rails, MySQL, PCI DSS, and any Technical Consulting |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#9 | |
Too lazy to set a custom title
Join Date: Jan 2002
Location: Holland
Posts: 9,870
|
Quote:
replace $random = rand(0,count($urls)); with $random = rand(0,count($urls)-1);
__________________
Don't let greediness blur your vision | You gotta let some shit slide icq - 441-456-888 |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#10 |
Confirmed User
Industry Role:
Join Date: Jan 2003
Location: Los Angeles
Posts: 736
|
ha! yea looks like the sudafed is affecting my judgement more than i previously thought
__________________
Tanguy 0x7a69 inc. Programmer/President/CEO http://www.0x7a69.com A Leader in Programming since 1996 PHP, Ruby on Rails, MySQL, PCI DSS, and any Technical Consulting |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#11 | |
Too lazy to set a custom title
Join Date: Jan 2002
Location: Holland
Posts: 9,870
|
Quote:
![]()
__________________
Don't let greediness blur your vision | You gotta let some shit slide icq - 441-456-888 |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#12 |
Too lazy to set a custom title
Industry Role:
Join Date: May 2004
Location: West Coast, Canada.
Posts: 10,217
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#13 |
<&(©¿©)&>
Industry Role:
Join Date: Jul 2002
Location: Chicago
Posts: 47,882
|
using array_rand is probably more straightforward...
![]()
__________________
Custom Software Development, email: woj#at#wojfun#.#com to discuss details or skype: wojl2000 or gchat: wojfun or telegram: wojl2000 Affiliate program tools: Hosted Galleries Manager Banner Manager Video Manager ![]() Wordpress Affiliate Plugin Pic/Movie of the Day Fansign Generator Zip Manager |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#14 |
Now choke yourself!
Industry Role:
Join Date: Apr 2006
Posts: 12,085
|
Certainly takes out some minor overhead by calling count() manually for each parse. I'd suggest this as well for something as simple-tarded as mentioned.
Code:
<?php $urls = array( 'http://www.google.com', 'http://www.msn.com', 'http://www.bing.com', 'http://www.webcrawler.com', 'http://www.dogpile.com', ); header("location: ". array_rand(array_flip($urls), 1)); ?>
__________________
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#15 | |
Too lazy to set a custom title
Industry Role:
Join Date: May 2004
Location: West Coast, Canada.
Posts: 10,217
|
Quote:
Code:
<?php $urls[] = "url1"; $urls[] = "url2"; $urls[] = "url3"; $urls[] = "url4"; $urls[] = "url5"; shuffle($urls); header('location: '.$urls[0]); ?> |
|
![]() |
![]() ![]() ![]() ![]() ![]() |