header("Location:$f[www]");

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
supaseeds
Forum Newbie
Posts: 13
Joined: Tue Jul 13, 2004 8:09 am

header("Location:$f[www]");

Post by supaseeds »

feyd | LAST WARNING use

Code: Select all

tags when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

Code: Select all

<?php
 include ( "defaults.php" );
 include ( "connect.php" );

  $r=mysql_query("SELECT www, webcounter FROM $db_users WHERE selector=$_GET[ID]") or die 

(mysql_error());
  $f=mysql_fetch_array($r);

   $f[webcounter]++;
   mysql_query("UPDATE $db_users SET webcounter=$f[webcounter] WHERE selector=$_GET[ID]") 

or die (mysql_error());


    header("Location:$f[www]");

 mysql_close();
 exit();

?>
Hey, Im running PHP mydirectory and when a link is clicked to run out.php it will update that someone clicked the link in the MYSQL database but won't show the link, just: http://www.mysite.com/dir/out.php?ID=1

If I swap header("Location:$f[www]"); for echo "$f[www]"; it will display the link the so theres no problem retrieving that, thus the problem must be with the header and location command. Any way round this?? Many thanks...


feyd | LAST WARNING use

Code: Select all

tags when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you really should quote your named array indices..

as for header('Location: ......'), it doesn't print anything in a browser, it's sent outside the html/output stream... sorta..
supaseeds
Forum Newbie
Posts: 13
Joined: Tue Jul 13, 2004 8:09 am

Post by supaseeds »

Is there any different code I can use besides header(location) to direct the php to a web address?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

header:location is used for automatic redirection. If you don't want that, you'll need to echo a link/javascript
djot
Forum Contributor
Posts: 313
Joined: Wed Jan 14, 2004 10:21 am
Location: planet earth
Contact:

why quote

Post by djot »

Hi,
you really should quote your named array indices..
Why quote the indices, for what reason?


djot
-
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

In case that php every brings out a keyword that matches what you have in the array indices. If its unquoted then php will assume that your refering to the keyword and not the array indices.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

or referring to a constant, which causes it to waste time searching through the variable space looking for a name, then sending a notice to the logs that it didn't find it.. Plus there have been a few instances where not quoting a string caused the bug in question.
Post Reply