Jump to content


Photo

somethign wrong with script


  • Please log in to reply
5 replies to this topic

#1 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 06 July 2006 - 01:58 PM

What am I doing wrong here
$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";
}
http://www.funnyemai...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.

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#2 CheesierAngel

CheesierAngel
  • Members
  • PipPipPip
  • Advanced Member
  • 105 posts
  • LocationBelgium

Posted 06 July 2006 - 03:03 PM

Is there a reason you place a space between your else and if's ?
I mostly use
<?php
if(...) {
  ...
} elseif(...) {
  ...
} else {
  ...
}
?>

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.



#3 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 06 July 2006 - 03:25 PM

<?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";
}
?>
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.funnyemai...com/display.php

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#4 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 06 July 2006 - 04:20 PM

Still can't seem to get this to work right?

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#5 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 06 July 2006 - 04:26 PM

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

#6 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 06 July 2006 - 04:41 PM

I fixed it I just changed my regular expression around a little.

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users