GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Need PHP basic help (https://gfy.com/showthread.php?t=199165)

the indigo 11-18-2003 06:52 PM

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!

TonyL 11-18-2003 06:57 PM

If I understand your need correctly this should work:

PHP Code:

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


-Tony

richard 11-18-2003 06:58 PM

Noob!

PHP Code:

<?php
$rid 
$_GET['rid'];
$url "http://www.sponsor.com?rid=" $rid;
echo 
"<a href=\"$url\">click me<a/>";
?>

:)

hornycash 11-18-2003 07:00 PM

PHP Code:

<? echo "$rid"; ?>


the indigo 11-18-2003 07:16 PM

great, thanks guys

Zer0 11-18-2003 07:51 PM

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"...

Script Dude 11-18-2003 07:56 PM

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.

hibbidiji 11-18-2003 08:57 PM

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

Zer0 11-18-2003 09:04 PM

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.

Dugan 11-18-2003 09:11 PM

how come scripting always comes in so small?
specifically php

hibbidiji 11-18-2003 09:11 PM

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

JDog 11-18-2003 09:25 PM

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

Script Dude 11-18-2003 09:40 PM

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'];?>



All times are GMT -7. The time now is 01:51 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123