Ninjakreborn Posted July 6, 2006 Share Posted July 6, 2006 What am I doing wrong here[code]$funnyurl = $site . $funnyurl;if (preg_match("/[.txt]{4}/i", $funnyurl)){require_once("./includes/view_text.php");}else if (preg_match("/[.jpg|.gif|.jpeg|.bmp|.tiff]{4}/i",$funnyurl)) {require_once("./includes/view_picture.php");}else if (preg_match("/[.mov]{4}/i",$funnyurl)) {require_once("./includes/view_quicktime.php");}else if (preg_match("/[.ram|.rm|.ra|.rpm]{4}/i",$funnyurl)) {require_once("./includes/view_realmedia.php");}else if (preg_match("/[.asf|.wma|.wmv|.wma|.wm|.asf|.avi|.mpeg|.mpg|.mp2|.mp3|.mid|.midi|.wav]{4}/i",$funnyurl)) {require_once("./includes/view_windowsmedia.php");}else if (preg_match("/[.swf|.swc|flv]{4}/i",$funnyurl)) {require_once("./includes/view_flash.php");}else {echo "No file exists at this location";}[/code]http://www.funnyemailforwards.com/display.phpThe problem is currently, it shows a media player file it shouldn't were did I misformat my code? It isn't suppose to show anything unless something matches one of those filetypes, it was working right all the way down to the point where I added inelse if (preg_match("/[.asf|.wma|.wmv|.wma|.wm|.asf|.avi|.mpeg|.mpg|.mp2|.mp3|.mid|.midi|.wav]{4}/i",$funnyurl)) {require_once("./includes/view_windowsmedia.php");}Now it tried to show that one whether it matches or not. Quote Link to comment https://forums.phpfreaks.com/topic/13843-somethign-wrong-with-script/ Share on other sites More sharing options...
CheesierAngel Posted July 6, 2006 Share Posted July 6, 2006 Is there a reason you place a space between your else and if's ?I mostly use [code]<?phpif(...) { ...} elseif(...) { ...} else { ...}?>[/code]I also noticed you are missing a dot in your last preg_match =:> [.swf|.swc|<b>.</b>flv]{4}This will not solve your problem but it's certainly a 'mini' bug in your script. Quote Link to comment https://forums.phpfreaks.com/topic/13843-somethign-wrong-with-script/#findComment-53899 Share on other sites More sharing options...
Ninjakreborn Posted July 6, 2006 Author Share Posted July 6, 2006 [code]<?php$funnyurl = $site . $funnyurl;if (preg_match("/[.txt]{4}/i", $funnyurl)){require_once("./includes/view_text.php");}elseif (preg_match("/[.jpg|.gif|.jpeg|.bmp|.tiff]{4}/i",$funnyurl)) {require_once("./includes/view_picture.php");}elseif (preg_match("/[.mov]{4}/i",$funnyurl)) {require_once("./includes/view_quicktime.php");}elseif (preg_match("/[.ram|.rm|.ra|.rpm]{4}/i",$funnyurl)) {require_once("./includes/view_realmedia.php");}elseif (preg_match("/[.asf|.wma|.wmv|.wma|.wm|.asf|.avi|.mpeg|.mpg|.mp2|.mp3|.mid|.midi|.wav]{4}/i",$funnyurl)) {require_once("./includes/view_windowsmedia.php");}elseif (preg_match("/[.swf|.swc|.flv]{4}/i",$funnyurl)) {require_once("./includes/view_flash.php");}else {echo "No file exists at this location";}?>[/code]I took care of all those, I was getting confused with java script, I mostly use javascript or did.The next question I had is why isn't it working now, it's still having the same problemhttp://www.funnyemailforwards.com/display.php Quote Link to comment https://forums.phpfreaks.com/topic/13843-somethign-wrong-with-script/#findComment-53913 Share on other sites More sharing options...
Ninjakreborn Posted July 6, 2006 Author Share Posted July 6, 2006 Still can't seem to get this to work right? Quote Link to comment https://forums.phpfreaks.com/topic/13843-somethign-wrong-with-script/#findComment-53960 Share on other sites More sharing options...
kenrbnsn Posted July 6, 2006 Share Posted July 6, 2006 What does $funnyurl contain?Can you use a combination of the parse_url() and pathinfo() functions to get the file extension and then use a switch statement to include the proper file?Ken Quote Link to comment https://forums.phpfreaks.com/topic/13843-somethign-wrong-with-script/#findComment-53965 Share on other sites More sharing options...
Ninjakreborn Posted July 6, 2006 Author Share Posted July 6, 2006 I fixed it I just changed my regular expression around a little. Quote Link to comment https://forums.phpfreaks.com/topic/13843-somethign-wrong-with-script/#findComment-53977 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.