Forum Moderators: coopster

Message Too Old, No Replies

Doesn't read my variables....

         

SNOWmanx

2:21 am on Aug 12, 2005 (gmt 0)

10+ Year Member



OK, there's a big problem with my script, but I dunno what. My script says:
if ($act == upload) {
print "act == upload";
}

the URL ends with?act=upload

I put that script to test the variable act, but it doesn't output anything. I can't show you the site for security reasons. PLEASE HELP!

coopster

2:30 am on Aug 12, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



When comparing strings you need to enclose them in quotation marks or else PHP is going to think they are a constant. Note the quotation marks around the word "upload" in the comparison:
if ($act == 'upload') { 
print "act == upload";
}

Why are you printing out the phrase, "act == upload" ...?

mcibor

9:45 am on Aug 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Why should it output something? You don't set the variable $act.

If you use url with?act=upload ending then use $_GET:

if ($_GET["act"] == "upload") {
print "Variable act is set to upload";
}

Or if you really want the $act variable you may use this structure:

if (($act = $_GET["act"]) == "upload") {
print "Variable act is set to $act";//will output the same as above
}

Hope this helps
Michal Cibor

PS. Why did you printed act == upload? It was just text, not comparison.