PDA

View Full Version : PHP & html question



Bok
10-25-2004, 10:11 AM
Got a question for any php developers out there.

In my new version of the stats I'm doing the front end entirely in php. However I'm having problems displaying teams which have spaces in them.

I'm sure I've had this working before but can't quite seem to get it to work now.

i.e. in my DB I have stored team=Dutch Power Cows

my php script reads this for Free-DC

http://stats.free-dc.org/new/teamstats.php?proj=tsc&team=Free-DC

but how to I put in Dutch Power Cows into that URL and then have the script decode it ?

I've messed about putting in %20's, +'s and also using urldecode etc, but without success. I'm sure it's something obvious I'm overlooking but would appreciate any insight!

Bok :cheers:

Darkness Productions
10-25-2004, 11:04 AM
First, I must suggest not using names, but using numbers. Much simpler. :)

But if you're going to use names, check out php's urldecode (http://us2.php.net/manual/en/function.urldecode.php) and urlencode (http://us2.php.net/manual/en/function.urlencode.php) to make the text nice and usable :)

Bok
10-25-2004, 11:12 AM
That's what I've been trying.

When I put this in

http://stats.free-dc.org/new/teamstats.php?proj=d2ol&team=Dutch%20Power%20Cows

and then try

$team2=urldecode($team);

team2 is DutchPowerCows;

similarly if I do

$team2=htmlspecialchars(urldecode($team));

I could use the projectrank for the teams instead, it's just that putting that as the index and updating the index often is not nice :)

Bok

Darkness Productions
10-25-2004, 04:16 PM
Form test

http://www.dp.cx/pub/bok.php

Source code

http://www.dp.cx/pub/bok.phps

Bok
10-25-2004, 04:25 PM
Thanks DP,

I've actually just fixed it, though fix is not a good word here. I think I should throw myself off a virtual cliff :(

Remebering the name of my variables (i.e. $team ) .... I had an

include '../generalconfig.inc';

at the top of my script (I use it in all of the scripts) which contained (amongst other things)

$team = ereg_replace (' ','', $team);
$team = ereg_replace ('.html','', $team);


:bang: :bang: :bang: :bang: :bang: :bang: :bonk: :bonk:

/me feels stupid

Bok

Darkness Productions
10-26-2004, 08:26 AM
:bonk: