-1

A seemingly simple question, but i'm not getting what is wrong with this one. I have a file upload button that passes ?upload=success in the URL. I want to show a message when upload is completed; however, even when $upload is not set, I still get the message printed.

Here's the code:

$upload = "";
echo "Upload status: ".$upload;

if ($upload = "success") {
    echo "<h3>Upload completed <br></h3>";
} else {
    echo "";
}

I don't get why:

  • when $upload is set to "" the if statements go through and prints the string;
  • when I complete an upload and I have ?upload=success, the echo "Upload status: ".$upload; return nothing ( and obviously the Upload completed message still gets printed)

Thanks to anybody that will spend a minute to help me :)

1 Answers1

1

Your are using assignment = instead of comparison ==

if ($upload == "success") {
    echo "<h3>Upload completed <br></h3>";
} else {
    echo "";
}
ket-c
  • 211
  • 1
  • 10