Jump to content

PHP $_GET


Recommended Posts

Yeah, I seem to be overlooking something really simple again today, but I can't figure it out. (Yeah I sent this as a PM but I thought I should put it here instead.)

 

Source:

<?php
    $filename = $_GET['file'];
    $location = $_GET['where'];
    if ($filename) {
        if ($location = "main") {
            print($filename . ' - ' . $location);
        } else if ($location = "home") {
            print($filename . ' - ' . $location);
        } else if ($location = "scoizzle") {
            print($filename . ' - ' . $location);
        }
    }
?>

 

No matter what I put for "where", I get $location printed as "main". So if I go to

, they both print "test.txt - main".

 

Thanks,

~Derek

Link to comment
Share on other sites

Should be == instead of =.

 

if ($location == "main")

 

<?php
        $filename = $_GET['file'];
        $location = $_GET['where'];
        if ($filename) {
                if ($location == "main") {
                        print($filename . ' - ' . $location);
                } else if ($location == "home") {
                        print($filename . ' - ' . $location);
                } else if ($location == "scoizzle") {
                        print($filename . ' - ' . $location);
                }
        }
?>

 

Link to comment
Share on other sites

Should be == instead of =.

 

omg I swear I tried that already (because Java uses "==" too), but I must have forgotten to FTP or something >.>

 

Thanks--again.

 

P.S.: Yeah, I'm updating my Profile and signature, etc. I figure it's about 2 years overdue. :S

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...