If HTTP Referrer = Ziltch.. How?

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
djwk
Forum Commoner
Posts: 56
Joined: Tue Mar 07, 2006 2:14 pm

If HTTP Referrer = Ziltch.. How?

Post by djwk »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Heres My Code:

Code: Select all

<?

$ref = $_SERVER['HTTP_REFERER'];

$file = "data/ref.dat";
$fp = fopen($file, "w");
fwrite($fp, $ref);
fclose($fp);

?>
I Tried:

Code: Select all

<?

$ref = $_SERVER['HTTP_REFERER'];

if ($ref = "") {
   
   $echo "Unknown";

} else {
   
   $file = "data/ref.dat";
   $fp = fopen($file, "w");
   fwrite($fp, $ref);
   fclose($fp);

}

?>
However this doesn't work, it just writes nothing to ref.dat all the time, wondered if anyone could help me fix this?


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

hint: = vs == issue.
djwk
Forum Commoner
Posts: 56
Joined: Tue Mar 07, 2006 2:14 pm

Post by djwk »

Sorry about using

Code: Select all

instead of

Code: Select all

and what do you mean "Hint: = vs == issue."
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

What he means is that = is an assignment operator.

Hence your if statement will always be true. == is a comparison operator.

Change your if statement to

Code: Select all

if ($blah == $blah) {

}
djwk
Forum Commoner
Posts: 56
Joined: Tue Mar 07, 2006 2:14 pm

Post by djwk »

omg lmao, what an idiot! :P

Thanks lol
Post Reply