Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 06-12-2008, 11:48 AM Error in php
goheadtry's Avatar
Webmaster Talker

Posts: 730
Name: John
Location: United States of America, California
Trades: 0
Okay my script was having a problem some one told me to


change this
PHP Code:
$filename preg_replace('/[\\\/:*?"<>|]/'''$filename); 
Advice given: Put a \ before the colon, so it's '/[\\\/\:
to

PHP Code:
$filename preg_replace('/[\\\/\:*?"<>|]/'''$filename); 
because I was getting this error(Below)

Warning: preg_replace() [function.preg-replace]: Unknown modifier ':' in /home/forbushj/public_html/uploadscript.php on line 31
Sorry, there was a problem uploading your file.

Now I am getting another error after doing this
the new error is:(Below)

Warning: preg_replace() [function.preg-replace]: Unknown modifier '\' in /home/forbushj/public_html/uploadscript.php on line 31
Sorry, there was a problem uploading your file.

This is my complete script and I need some help getting rid of this error in the script

PHP Code:
<?php
  $uploaded_size 
$_FILES['uploaded']['size'];
  
$target $filepath.$_FILES['uploaded']['name'];
  
$uploaded_type $_FILES['uploaded']['type'];
  
$filepath '/home/forbushj/www/vidtemp/';
  
$filetypes = array('video/x-ms-asf''video/x-msvideo''video/x-flv''video/quicktime''video/mp4''video/mpeg''video/x-ms-wmv');
  
$title addslashes($_GET['title']);
  
$descr addslashes($_GET['descr']);
  
$src addslashes($_GET['src']); 
// Check for errors:
if (addslashes($_GET['agree'] = 0))
{
echo(
"You must agree or you can't upload");
}
else
{

if (!empty (
$title) || !empty ($descr) || !empty ($src) || !empty ($_FILES['uploaded']['tmp_name'])) {
      if (
$uploaded_size 104857600$error_msg .= 'Your file is too large. Only files 100MB and less are allowed<br />';
      if (!
in_array($uploaded_type$filetypes)) $error_msg .= 'You may only upload movies.<br />';
      
      if (
$error_msg)
      {
        echo 
$error_msg 'Sorry your file was not uploaded';
      }
      else if (
move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
      {
        
$file $_FILES['uploaded']['tmp_name'];
        
$ext substr($file, ((strrpos($file'.') !== false) ? strrpos($file'.') : strlen($file)), strlen($file));
        
$filename date('Y-m-d-H-i-s') . '_' str_replace(' ''_'basename($file$ext));
        
$filename preg_replace('/[\\\/\:*?"<>|]/'''$filename);
        
        if (
is_file($filepath $file))
        {
          
$output = array();
          
          
exec('ffmpeg -i "' escapeshellarg($file) . '" -an -ss 00:00:03 -t 00:00:01 -r 1 -y -s 150x100 -f mjpeg "/home/forbushj/www/pic/video/' escapeshellarg($filename) . '.jpg"'$output$exit_code_pic);
          
exec('ffmpeg -i "' escapeshellarg($file) . '" -ar 22050 -ab 32 -f flv -s 320x240 "/home/forbushj/www/vidd/' escapeshellarg($filename) . '.flv"'$output$exit_code_vid);
          
          if (!
is_array($output)) $error_msg 'Sorry, there was a problem uploading your file.';
          
          if (
$exit_code)
          {
            
error_log('ffmpeg exec returned ' $exit_code);
            
$error_msg 'Sorry, there was a problem uploading your file.';
          }
          
          if (!
$error_msg)
          {
    
mysql_connect("localhost""REMOVED""REMOVED") or die(mysql_error());
            
mysql_query("
              INSET INTO forbushj_onetest.video (title, descr, pic, locat, src)
              VALUES (
                '" 
mysql_real_escape_string($title) . "',
                '" 
mysql_real_escape_string($descr) . "',
                '" 
mysql_real_escape_string($filename ".jpg") . "',
                '" 
mysql_real_escape_string($filename ".flv") . "',
                '" 
mysql_real_escape_string($src) . "'
              )
            "
);
            echo 
"upload successful";
            
unlink(' . escapeshellarg($file) . ');
          }
        }
        else
        {
          
$error_msg 'Sorry, there was a problem uploading your file.';
        }
      }
      else
      {
        
$error_msg 'Sorry, there was a problem uploading your file.';
      }
      
      if (
$error_msg) echo $error_msg;
} else {
    echo 
'You must fill out all fields!';
}
}
  
?>
Help me if you can I am trying to get rid of the error.
__________________
Free $1 gift card when you signup at
Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


Last edited by goheadtry; 06-12-2008 at 12:08 PM..
goheadtry is offline
Reply With Quote
View Public Profile Visit goheadtry's homepage!
 
 
Register now for full access!
Old 06-12-2008, 02:06 PM Re: Error in php
Arenlor's Avatar
Ultra Talker

Posts: 462
Name: Jerod Lycett
Location: /home/arenlor
Trades: 0
First off, I don't think any of those characters are allowed in valid filenames so I don't think you'll ever encounter them. Try this:
preg_replace('/\[\\\/\:\*\?\"\<\>\|\]/','',$filename);
__________________
PHP Code:
<?php echo "Hello World"?>
HTML Code:
<html><head><title>Hello World</title></head><body><p>Hello World</p></body></html>
Arenlor is offline
Reply With Quote
View Public Profile Visit Arenlor's homepage!
 
Old 06-14-2008, 08:33 AM Re: Error in php
vectorialpx's Avatar
Extreme Talker

Posts: 249
Name: octavian
Location: Bucharest
Trades: 0
or http://www.php.net/is_file
__________________
you can
Please login or register to view this content. Registration is FREE
vectorialpx is offline
Reply With Quote
View Public Profile Visit vectorialpx's homepage!
 
Old 06-14-2008, 05:37 PM Re: Error in php
Arenlor's Avatar
Ultra Talker

Posts: 462
Name: Jerod Lycett
Location: /home/arenlor
Trades: 0
He's trying to strip characters from the file name.
__________________
PHP Code:
<?php echo "Hello World"?>
HTML Code:
<html><head><title>Hello World</title></head><body><p>Hello World</p></body></html>
Arenlor is offline
Reply With Quote
View Public Profile Visit Arenlor's homepage!
 
Old 06-16-2008, 09:49 AM Re: Error in php
vectorialpx's Avatar
Extreme Talker

Posts: 249
Name: octavian
Location: Bucharest
Trades: 0
ups!... got that

my bad!
__________________
you can
Please login or register to view this content. Registration is FREE
vectorialpx is offline
Reply With Quote
View Public Profile Visit vectorialpx's homepage!
 
Old 06-16-2008, 11:21 AM Re: Error in php
goheadtry's Avatar
Webmaster Talker

Posts: 730
Name: John
Location: United States of America, California
Trades: 0
Yes and it still has a bug
with the same part, even after do that.
__________________
Free $1 gift card when you signup at
Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

goheadtry is offline
Reply With Quote
View Public Profile Visit goheadtry's homepage!
 
Old 06-16-2008, 07:55 PM Re: Error in php
Arenlor's Avatar
Ultra Talker

Posts: 462
Name: Jerod Lycett
Location: /home/arenlor
Trades: 0
Why are you stripping those characters btw?
__________________
PHP Code:
<?php echo "Hello World"?>
HTML Code:
<html><head><title>Hello World</title></head><body><p>Hello World</p></body></html>
Arenlor is offline
Reply With Quote
View Public Profile Visit Arenlor's homepage!
 
Old 06-17-2008, 03:47 PM Re: Error in php
goheadtry's Avatar
Webmaster Talker

Posts: 730
Name: John
Location: United States of America, California
Trades: 0
so that I have friendly file names and so someone can't use the # symbol etc to change the sql query through the upload box.
__________________
Free $1 gift card when you signup at
Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

goheadtry is offline
Reply With Quote
View Public Profile Visit goheadtry's homepage!
 
Old 06-17-2008, 09:22 PM Re: Error in php
Arenlor's Avatar
Ultra Talker

Posts: 462
Name: Jerod Lycett
Location: /home/arenlor
Trades: 0
A filename cannot contain any of the following characters: \ / : * ? " < > |
That is true on Windows and Linux. So if you're worried about other stuff just work on them.
__________________
PHP Code:
<?php echo "Hello World"?>
HTML Code:
<html><head><title>Hello World</title></head><body><p>Hello World</p></body></html>
Arenlor is offline
Reply With Quote
View Public Profile Visit Arenlor's homepage!
 
Old 06-18-2008, 02:14 PM Re: Error in php
goheadtry's Avatar
Webmaster Talker

Posts: 730
Name: John
Location: United States of America, California
Trades: 0
I just want to strip out every thing except for numbers and letters and if there is anything else including a space replace it with the - symbol how is this done?
__________________
Free $1 gift card when you signup at
Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

goheadtry is offline
Reply With Quote
View Public Profile Visit goheadtry's homepage!
 
Reply     « Reply to Error in php
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.41581 seconds with 12 queries