Jump to content

Recommended Posts

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.php
The 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 in
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");
}
Now it tried to show that one whether it matches or not.
Link to comment
https://forums.phpfreaks.com/topic/13843-somethign-wrong-with-script/
Share on other sites

Is there a reason you place a space between your else and if's ?
I mostly use
[code]
<?php
if(...) {
  ...
} 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.

[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 problem
http://www.funnyemailforwards.com/display.php
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.