divadiva Posted January 15, 2009 Share Posted January 15, 2009 I am trying to run an IF statement here. If my weblink is ($fdl=@fopen($fileString ,'r')&& $_GET["entryPoint"]== removeme && $_GET["entryPoint"]== campaign_tracker2 && $_GET["entryPoint"]== campaign_tracker)I should get access to the file.If the $_GET in the link is not equal to removeme,campaigntracker or campaigntracker,I should get "Cannot open open. ANy help will be apprciated; This is the link http://www.xyz.com/index.php?entryPoint=campaign_trackerv2&track=a67fd05b-0804-e4bb-456e-496f69e036bc if($fdl=@fopen($fileString ,'r')&& $_GET["entryPoint"]== removeme && $_GET["entryPoint"]== campaign_tracker2 && $_GET["entryPoint"]== campaign_tracker){ //Check for File existence $contentType = 'text/html'; header("Cache-Control: ");// leave blank to avoid IE errors header("Pragma: "); // leave blank to avoid IE errors header("Content-type: $contentType"); fpassthru($fdl); } else { die("Cannot Open File!"); } Link to comment https://forums.phpfreaks.com/topic/140971-solved-help-with-if-statement/ Share on other sites More sharing options...
rhodesa Posted January 15, 2009 Share Posted January 15, 2009 first, you need single quotes around those values...and it should be || or OR. but in_array is easier: if($fdl=@fopen($fileString ,'r') && in_array($_GET["entryPoint"], array('removeme','campaign_tracker2','campaign_tracker')){ //Check for File existence $contentType = 'text/html'; header("Cache-Control: ");// leave blank to avoid IE errors header("Pragma: "); // leave blank to avoid IE errors header("Content-type: $contentType"); fpassthru($fdl); } else { die("Cannot Open File!"); } Link to comment https://forums.phpfreaks.com/topic/140971-solved-help-with-if-statement/#findComment-737823 Share on other sites More sharing options...
divadiva Posted January 15, 2009 Author Share Posted January 15, 2009 Thankyou for replying. I get this error unexpected '{' in pn if($fdl=@fopen($fileString ,'r') && in_array($_GET["entryPoint"], array('removeme','campaign_tracker2','campaign_tracker')){ Link to comment https://forums.phpfreaks.com/topic/140971-solved-help-with-if-statement/#findComment-737824 Share on other sites More sharing options...
rhodesa Posted January 15, 2009 Share Posted January 15, 2009 needs one more ( if($fdl=@fopen($fileString ,'r') && in_array($_GET["entryPoint"], array('removeme','campaign_tracker2','campaign_tracker'))){ Link to comment https://forums.phpfreaks.com/topic/140971-solved-help-with-if-statement/#findComment-737831 Share on other sites More sharing options...
divadiva Posted January 15, 2009 Author Share Posted January 15, 2009 Thankyou once again.It works but I am unable to open web page which I was able to before.But now I cannot access that page for some reason.Could it be because of the $_GET I am using. I mean the if statement .Please see my code. This is the webpage : http://www.xyz.com/index.php?entryPoint=campaign_trackerv2&track=a67fd05b-0804-e4bb-456e-496f69e036bc . $fileName = "index.php"; //Provide a valid file name. $fileLink ='?entryPoint='.$_GET["entryPoint"].'&identifier='.$_GET["identifier"];//Add the additional links $fileString = $fileDir.'/'.$fileName.$fileLink;//Append all the links if(!$fdl=@fopen($fileString ,'r') && in_array($_GET["entryPoint"], array('removeme','campaign_tracker2','campaign_tracker'))){//Looking for a reason why webpage cannot be opened .Before I was able to open the page. die("You dont have rights to open the file!"); } else { $contentType = 'text/html'; header("Cache-Control: ");// leave blank to avoid IE errors header("Pragma: "); // leave blank to avoid IE errors header("Content-type: $contentType"); fpassthru($fdl); } ?> Link to comment https://forums.phpfreaks.com/topic/140971-solved-help-with-if-statement/#findComment-737840 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.