Thomisback Posted March 8, 2008 Share Posted March 8, 2008 Hi, I am trying to make a php script which retrieves a variable via flash and checks if it exists and returns back a different variable. For some reason it always says the does not exist, even if it does. My code: [code] <? $usr=$_POST['usr']; $filename = 'http://www.mydomain.com/$usr/test.txt'; if (file_exists($filename)) { $info = "Already exists"; echo("&info=$info"); } else { $info = "Success!"; echo("&info=$info"); } ?> Does anyone see what it wrong with the code? Thank you very much![/code] Quote Link to comment Share on other sites More sharing options...
uniflare Posted March 8, 2008 Share Posted March 8, 2008 use double quotes when inserting variables without concatenation: $filename = 'http://www.mydomain.com/$usr/test.txt'; should be either: $filename = "http://www.mydomain.com/$usr/test.txt"; or concatenate: $filename = 'http://www.mydomain.com/'.$usr.'/test.txt'; hope this helps, Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted March 8, 2008 Share Posted March 8, 2008 In addition to what uniflare posted to get the $usr variable to work, the last time I checked, file_exists() does not work with http/https protocols. If this is a local file, you need to use a file system path, not a URL, in the file_exists() function. Quote Link to comment Share on other sites More sharing options...
Thomisback Posted March 8, 2008 Author Share Posted March 8, 2008 Thanks again! I am going to try it in a second and I will let you know guys know my results Thanks, your help is very appreciated! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.