Page 1 of 1

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

Posted: Tue Jul 20, 2004 2:45 am
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]

Posted: Tue Jul 20, 2004 3:05 am
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..

Posted: Tue Jul 20, 2004 3:20 am
by supaseeds
Is there any different code I can use besides header(location) to direct the php to a web address?

Posted: Tue Jul 20, 2004 4:19 am
by feyd
header:location is used for automatic redirection. If you don't want that, you'll need to echo a link/javascript

why quote

Posted: Tue Jul 20, 2004 6:39 am
by djot
Hi,
you really should quote your named array indices..
Why quote the indices, for what reason?


djot
-

Posted: Tue Jul 20, 2004 7:11 am
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.

Posted: Tue Jul 20, 2004 11:07 am
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.