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.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 11-18-2003, 06:52 PM   #1
the indigo
Confirmed User
 
the indigo's Avatar
 
Industry Role:
Join Date: Sep 2001
Location: North America
Posts: 2,016
Need PHP basic help

Okay, pretty simple stuff but I'm not able to find out wtf doesn't work.

I need the "rid" from http://www.blah.com/gallery.php?rid=2000 to be added to each sponsor link. ie:

http://www.blah.com/gallery.php?rid=2000
goes to
http://www.sponsor.com/tour.php?rid=2000

And if I type a different "rid", it will automatically modify all the links.

Currently, all pages are in .php and links look like this: http://www.sponsor.com/tour.php?rid=

I'm sure I have something to add in the header in php. thanks!
the indigo is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-18-2003, 06:57 PM   #2
TonyL
Confirmed User
 
TonyL's Avatar
 
Join Date: Feb 2002
Location: "A measure of a man is his post count". Write that down.
Posts: 900
If I understand your need correctly this should work:

PHP Code:
http://www.sponsor.com/tour.php?rid=<?echo $rid;?>

-Tony

Last edited by TonyL; 11-18-2003 at 06:59 PM..
TonyL is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-18-2003, 06:58 PM   #3
richard
Confirmed User
 
Join Date: Feb 2001
Location: UK
Posts: 543
Noob!

PHP Code:
<?php
$rid 
$_GET['rid'];
$url "http://www.sponsor.com?rid=" $rid;
echo 
"<a href=\"$url\">click me<a/>";
?>
__________________
richard is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-18-2003, 07:00 PM   #4
hornycash
Confirmed User
 
Join Date: Jun 2002
Location: far beyond reality
Posts: 2,336
PHP Code:
<? echo "$rid"; ?>
hornycash is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-18-2003, 07:16 PM   #5
the indigo
Confirmed User
 
the indigo's Avatar
 
Industry Role:
Join Date: Sep 2001
Location: North America
Posts: 2,016
great, thanks guys
the indigo is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-18-2003, 07:51 PM   #6
Zer0
Registered User
 
Join Date: Aug 2003
Posts: 16
Another longer way to do it (which could have issues if your linking elsewhere off your site), but it would save time adding the code to each link... is just to get the page to open the original file as an input and go a preg_replace for all link tags adding ?rid=$rid to the end of the link values. Sure this is the longer way around and the page might load slightly slower, but hell I'm lazy and I don't want to spend the 3 secs it takes to do a search/replace on a page of code :P

Plus you ever seen the face of a graphic designer when they see "funny" code. They stop in their tracks with this strange look, then it... "what do I do with this"...
Zer0 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-18-2003, 07:56 PM   #7
Script Dude
Registered User
 
Join Date: Jun 2002
Location: Michigan
Posts: 86
Save the following to a file called fixlinks.php:
PHP Code:
<?php 
function FixLinks($buffer) {
    return isset(
$_GET['rid']) ? 
        
str_replace('rid=1000''rid=' $_GET['rid'], $buffer) : $buffer;
}

ob_start("FixLinks");
?>
Now once at the top of each of your gallery.php files put:
PHP Code:
<?php include 'fixlinks.php'?>
This will change all the links on the page of the form

http://www.sponsor.com/tour.php?rid=1000

rid=1000 is your default code if someone forgets to add an rid= parameter to the url or it gets lost.

Works on PHP 4.1 or later.

Alternatively, in your .htaccess file put
PHP Code:
<Files "\.php$">
php_value auto_prepend_file "fixlinks.php"
</Files
And all PHP files in that directory will automagically have their links redone and you don't have to change them in any way.

PHP Code:
<Files "\.html$">
php_value auto_prepend_file "fixlinks.php"
ForceType application/x-httpd-php 
</Files
With this all the html files in the directory will become PHP files and have their links rewritten.

I haven't tested any of this. You'll be lucky if it works.

Damn, the PHP highlighting colors are fugly on this board. and vBulleton mangles code. There is a \ in front of the .php and in front of .html in the .htacces file samples. you really will be lucky to get this to work.
Script Dude is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-18-2003, 08:57 PM   #8
hibbidiji
Confirmed User
 
Join Date: Sep 2002
Location: Las Vegas
Posts: 208
jesus what a fucking mess... man. if you want to do it.. in most cases the very first reply will work fine. If it DOESNT work, use the second one.. if you want to get confused and more than you wanted to deal with, try the other suggestions. Thing is, that the first one is the most tedious to code, but is most flexible. The second one will make it so that EVERY coded link on the page will go to the same place (defined by $url) not necessarily bad, but just not quite as flexible as doing it all by hand.

D
__________________
---------------
hibbidiji is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-18-2003, 09:04 PM   #9
Zer0
Registered User
 
Join Date: Aug 2003
Posts: 16
yeah agreed that the first is the simplest, but thin of the pain when it comes to adding that code to each link and you have a front end with the main graphic split into 40~50+ linked images... aaah the pain :P

But yeah, do it which ever way, it gets you the same result in the end.
Zer0 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-18-2003, 09:11 PM   #10
Dugan
Confirmed User
 
Industry Role:
Join Date: Nov 2003
Location: Online
Posts: 856
how come scripting always comes in so small?
specifically php
Dugan is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-18-2003, 09:11 PM   #11
hibbidiji
Confirmed User
 
Join Date: Sep 2002
Location: Las Vegas
Posts: 208
Quote:
Originally posted by Zer0
yeah agreed that the first is the simplest, but thin of the pain when it comes to adding that code to each link and you have a front end with the main graphic split into 40~50+ linked images... aaah the pain :P

But yeah, do it which ever way, it gets you the same result in the end.
lol. finally sound thinking we just have to remember that unless someone wants to get into scripting, its easier to learn little things one at a time. echo is fast and easy to understand... by the time we're doing regexp and shit its too much to learn at once and still get shit done. I would probably write a freaking admin to manage all the links through php+mysql with a custom apache mod to replace app my links.. it would take 5 hours to write and would save 20 minutes but thats what we programmers do hehe
__________________
---------------
hibbidiji is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-18-2003, 09:25 PM   #12
JDog
Confirmed User
 
Join Date: Feb 2003
Location: Canby, OR
Posts: 7,453
Quote:
Originally posted by hibbidiji


lol. finally sound thinking we just have to remember that unless someone wants to get into scripting, its easier to learn little things one at a time. echo is fast and easy to understand... by the time we're doing regexp and shit its too much to learn at once and still get shit done. I would probably write a freaking admin to manage all the links through php+mysql with a custom apache mod to replace app my links.. it would take 5 hours to write and would save 20 minutes but thats what we programmers do hehe
hehe I hear ya there! And I also agree that the first one is the easy one to do, and there is no use in preg_replace unless you're deciding about chinging links

jDoG
__________________
NSCash now powering ReelProfits.com
ALSO FEATURING: NSCash.com :: SoloDollars.com :: ReelProfits.com :: BiminiBucks.com :: VOD
PROGRAMS COMING SOON: Greedy Bucks :: Vengeance Cash
NOW OFFERING OVER 60 SITES
CONTACT :: JAMES SMITH :: CHIEF TECHNOLOGY OFFICER :: ICQ (711385133)
JDog is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-18-2003, 09:40 PM   #13
Script Dude
Registered User
 
Join Date: Jun 2002
Location: Michigan
Posts: 86
Quote:
Originally posted by TonyL
PHP Code:
http://www.sponsor.com/tour.php?rid=<?echo $rid;?>
If you want to do it this way and you have PHP 4.2 or better, this probably won't work.

This will work on PHP 4.1 or better:

PHP Code:
http://www.sponsor.com/tour.php?rid=<?echo $_GET['rid'];?>
Script Dude is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.