GetDotted Domains

Viewing Thread:
"How do I add PHP variables to make a URL?"

The "Freeola Customer Forum" forum, which includes Retro Game Reviews, has been archived and is now read-only. You cannot post here or create a new thread or review on this forum.

Wed 10/07/02 at 11:40
Regular
Posts: 787
I'm working on something at the moment and I'm using the "INCLUDE" tag to arrange a URL from three variable - "type", "id" & "format".

Here's the coding I've been trying to get to work:

if (file_exists("$type" + "$id" + "$format"))
{ include("$type" + "$id" + "$format"); $id++; }
else
{ include("nolink.html"); }
?>

the "nolink.html" bit works, which means that it hasn't assorted the URL how I want it. It should display a document as such:

news0001.html

You see "news" is the "type", "0001" is the "id" and ".html" is the "format". Clever, no! Except it doesn't work!

Also, I'm trying to increment the variable "$id", so that I can have other files below it. At the moment I'm using JavaScript style methods, which have worked for other tings, but not this. I'm also guessing that because the "$id" is an integer, that "%id" will have to be used, but I'll leave it up to you lot to tell me that.
Cheers!
Thu 11/07/02 at 15:42
Regular
"Eff, you see, kay?"
Posts: 14,156
You could use the float operator, but it's a bad way to do it. Glad it works.

Oh..

"foo" + "bar" will choke really horribly. "." to concatenate strings, "+" to concatenate floats (IE. to add up numbers). PHP is clever in spotting poeple's mistakes and correcting them, but I don't think it swaps +'s and .'s.
Wed 10/07/02 at 15:44
Regular
"It goes so quickly"
Posts: 4,083
Yeah, better to use single digits :o)
Wed 10/07/02 at 14:51
Regular
"Pouch Ape"
Posts: 14,499
It was the second one. I've got that increment thing sorted as well now! I had named the files 0001, 0002, 0003, etc. It gets mucked up that way, so I've changed them to 0, 1, 2, 3, etc

Cheers for your help!
Wed 10/07/02 at 14:03
Regular
"It goes so quickly"
Posts: 4,083
... and was it the seconds bit of code that worked, or the first on I posted?
Wed 10/07/02 at 14:02
Regular
"It goes so quickly"
Posts: 4,083
See if $id = $id + 1; works
Wed 10/07/02 at 13:20
Regular
"Pouch Ape"
Posts: 14,499
cjh wrote:
> Probably completly wrong as well :o)

No you're wrong - it works! Cheers CJH, that worked a treat!

One more problem though - how do I increment the variable? My "$id++" methoddoesn't seem to be working. Any ideas?
Wed 10/07/02 at 12:45
Regular
"It goes so quickly"
Posts: 4,083
Probably completly wrong as well :o)
Wed 10/07/02 at 12:33
"High polygon count"
Posts: 15,624
You're not very good, are you? ;-p
Wed 10/07/02 at 12:25
Regular
"It goes so quickly"
Posts: 4,083
Nope, things thats wrong again, try:

if (file_exists("$type$id$format")) {
include("$type$id$format");
$id++;
} else {
include("nolink.html");
}
?>
Wed 10/07/02 at 12:24
Regular
"It goes so quickly"
Posts: 4,083
Sorry, as in:

if (file_exists("$type", "$id", "$format")) {
include("$type$id$format");
$id++;
} else {
include("nolink.html");
}
?>

Freeola & GetDotted are rated 5 Stars

Check out some of our customer reviews below:

The coolest ISP ever!
In my opinion, the ISP is the best I have ever used. They guarantee 'first time connection - everytime', which they have never let me down on.
I am delighted.
Brilliant! As usual the careful and intuitive production that Freeola puts into everything it sets out to do. I am delighted.

View More Reviews

Need some help? Give us a call on 01376 55 60 60

Go to Support Centre

It appears you are using an old browser, as such, some parts of the Freeola and Getdotted site will not work as intended. Using the latest version of your browser, or another browser such as Google Chrome, Mozilla Firefox, or Opera will provide a better, safer browsing experience for you.