Reply
I am recieving an error with a php script and I need help correcting the error
Old 01-01-2008, 03:36 PM I am recieving an error with a php script and I need help correcting the error
goheadtry's Avatar
Webmaster Talker

Posts: 715
Name: John
Location: United States of America, California
I was wondering if someone could help me correct this error? please I am trying to make it so it can upload to this path "home/forbushj/uploadedvideo/"
then after conversions it copies the video file to this path home/forbushj/public_html/vidd/
the script runs from this path
home/forbushj/public_html/


That is the url to my upload form
* Below
Code:
http://www.technologyforever.com/addmovie.php
That is the script that processes the uploads and processes the file using a command line in the php script
* Below
Code:
http://www.technologyforever.com/upload.php
That is the script that processes the uploads and processes the file using a command line in the php script
I am getting an odd error message * BELOW
Code:
Warning:  unlink(movies\.flv) [function.unlink]: No such file or directory in /home/forbushj/public_html/upload.php on line 7

Warning:  unlink(movies\.gif) [function.unlink]: No such file or directory in /home/forbushj/public_html/upload.php on line 17
Your video has not been successfully uploaded
File sucessfully uploaded
PHP Code:
<html><body>
<?php

$ffmpeg 
"/home/forbushj/bin/ffmpeg/bin/ffmpeg";
function 
converttoflv$in$out )
{
  
unlink$out );
  
$cmd "$ffmpeg -v 0 -i $in -ar 11025 $out 2>&1";
  
$fh popen$cmd"r" );
  while( 
fgets$fh ) ) { }
  
pclose$fh );
}

function 
getthumbnail$in$out )
{
//was 300x200
  
unlink$out );
  
$cmd "$ffmpeg -i $in -pix_fmt rgb24 -vframes 1 -s 150x100 $out 2>&1";
  
$fh popen$cmd"r" );
  while( 
fgets$fh ) ) { }
  
pclose$fh );
}

function 
flv_import$upfile$fname$title )
{
  
$fname preg_replace'/\..*$/'''basename$fname ) );
  
$flvpath "$fname.flv";
  
$thumbpath "$fname.gif";

  
converttoflv$upfile"movies\\$flvpath" );
  
getthumbnail$upfile"movies\\$thumbpath" );

  
$linkID = @mysql_connect("THIS PART HAS BEEN REMOVED")
or die(
"Could not upload file database is down");
@
mysql_select_db("forbushj_onetest") or die("Could not select database");
// Retrieve the posted product information.
$vidtitle $_POST['vidname'];
$vidcategori $_POST['categories'];
$viddesc $_POST['viddes'];
$vidpic $_POST['vidpic'];
$vidsrcof $_POST['srcof'];
$vidfile $_POST['ufile'];
$vidpic $_POST['vidpic'];
$vidlocat $_POST['locat'];
$vidsrcof $_POST['srcof'];
// Insert the product information into the product table
$query "INSERT INTO video SET vidname='$vidtitle', viddes='$viddesc',
vidpic='$vidpic', locat='$vidlocat', srcof='$vidsrcof'"
;
$result mysql_query($query);
// Display an appropriate message
if ($result) echo "<p>Your video has been successfully uploaded</p>";
else echo 
"<p>Your video has not been successfully uploaded</p>";
  
}

flv_import$_FILES['movie']['tmp_name'], $_FILES['movie']['name'], $_POST['title'] );
?>
File sucessfully uploaded
</body></html>
-Thanks John AKA goheadtry as the user
goheadtry is offline
Reply With Quote
View Public Profile Visit goheadtry's homepage!
 
When You Register, These Ads Go Away!
Old 01-01-2008, 03:57 PM Re: I am recieving an error with a php script and I need help correcting the error
King Spam Talker

Posts: 1,083
Did you write this or modify an existing script?

I imagine your problem is in this line here, even though the error occurs later on.

$ffmpeg = "/home/forbushj/bin/ffmpeg/bin/ffmpeg";

Without having more information try deleting the last /bin/ffmpeg from the above line.

Not sure why the type is green now.

colbyt is offline
Reply With Quote
View Public Profile
 
Old 01-01-2008, 04:32 PM Re: I am recieving an error with a php script and I need help correcting the error
goheadtry's Avatar
Webmaster Talker

Posts: 715
Name: John
Location: United States of America, California
I modified an existing script but changed the script for my needs because mine needs additional fields for the options on upload

Code:
http://www.onlamp.com/pub/a/php/2007/05/24/creating-mytube-with-flex-and-php.html?page=1


Is where I got my information for making the script.
I changed ffmpeg to $ffmpeg and put the path of my ffmpeg file

Last edited by goheadtry : 01-01-2008 at 04:35 PM.
goheadtry is offline
Reply With Quote
View Public Profile Visit goheadtry's homepage!
 
Old 01-01-2008, 05:08 PM Re: I am recieving an error with a php script and I need help correcting the error
Skilled Talker

Posts: 73
Name: Mattias Nordahl
Location: Sweden
The error message clearely says that something goes wrong when your try to delete a file, using unlink(). It also says the error is that the file doesn't exists, so obviously it can't be deleted. The unlink() functions are placed within your converttoflv() and getthumbnail() functions.

When creating a new a new .flv or image file you just delete the old one if there is one with the same name. But, what if there isn't any with the same name(?). You simply need to check if there already exists a file with the same name, and if so delete it. If not, do nothing, just continue with the script.

Code:
if(file with name $out already exists)
    delete it
Check out the function file_exists() at php.net.
lizciz is offline
Reply With Quote
View Public Profile
 
Old 01-01-2008, 07:56 PM Re: I am recieving an error with a php script and I need help correcting the error
maxxximus's Avatar
Extreme Talker

Posts: 190
Name: Rob
Location: UK
The problem is with you variable $ffmpeg. You are attempting to access a local version of this variable within a function but it has not been assigned a value due to the concept of scope http://uk3.php.net/global.

You need to access the global version by using $GLOBALS[ffmpeg] instead of $ffmpeg.
PHP Code:
$cmd "$GLOBALS[ffmpeg] -v 0 -i $in -ar 11025 $out 2>&1"
maxxximus is offline
Reply With Quote
View Public Profile
 
Old 01-01-2008, 08:02 PM Re: I am recieving an error with a php script and I need help correcting the error
goheadtry's Avatar
Webmaster Talker

Posts: 715
Name: John
Location: United States of America, California
ffmpeg is not a variable it is an actual program. and $ffmpeg gives the location of the ffmpeg binary.
it is run by command line with php

Last edited by goheadtry : 01-01-2008 at 08:07 PM.
goheadtry is offline
Reply With Quote
View Public Profile Visit goheadtry's homepage!
 
Old 01-01-2008, 08:59 PM Re: I am recieving an error with a php script and I need help correcting the error
goheadtry's Avatar
Webmaster Talker

Posts: 715
Name: John
Location: United States of America, California
I am not finding this very helpful could someone possibly explain a bit more I am not quite sure what is messed up so I still need help on this post.
goheadtry is offline
Reply With Quote
View Public Profile Visit goheadtry's homepage!
 
Old 01-02-2008, 02:37 AM Re: I am recieving an error with a php script and I need help correcting the error
Skilled Talker

Posts: 73
Name: Mattias Nordahl
Location: Sweden
Did you try reading my post? If not, then please do.
And maxxximus is right about the scope. Your variable $ffmpeg is not accessable within your functions. Read the link he posted for explanation.

Last edited by lizciz : 01-02-2008 at 02:48 AM.
lizciz is offline
Reply With Quote
View Public Profile
 
Old 01-02-2008, 12:49 PM Re: I am recieving an error with a php script and I need help correcting the error
goheadtry's Avatar
Webmaster Talker

Posts: 715
Name: John
Location: United States of America, California
Wait the problem is still there even after using global
Unlink deletes a file correct?
How do I tell it what $in and $out are then for the variable to be a folder path and a file that is dynamic?
PHP Code:
<html><body>
<?php

$ffmpeg 
"/home/forbushj/bin/ffmpeg/bin/ffmpeg";
function 
converttoflv$in$out )
{
global 
$ffmpeg;
  
unlink$out );
  
$cmd "$ffmpeg -v 0 -i $in -ar 11025 $out 2>&1";
  
$fh popen$cmd"r" );
  while( 
fgets$fh ) ) { }
  
pclose$fh );
}

function 
getthumbnail$in$out )
{
global 
$ffmpeg;
//was 300x200
  
unlink$out );
  
$cmd "$ffmpeg -i $in -pix_fmt rgb24 -vframes 1 -s 150x100 $out 2>&1";
  
$fh popen$cmd"r" );
  while( 
fgets$fh ) ) { }
  
pclose$fh );
}

function 
flv_import$upfile$fname$title )
{
global 
$ffmpeg;
  
$fname preg_replace'/\..*$/'''basename$fname ) );
  
$flvpath "$fname.flv";
  
$thumbpath "$fname.gif";

  
converttoflv$upfile"movies\\$flvpath" );
  
getthumbnail$upfile"movies\\$thumbpath" );

  
$linkID = @mysql_connect("localhost","forbushj_uploadv","jfca123")
or die(
"Could not upload file database is down");
@
mysql_select_db("forbushj_onetest") or die("Could not select database");
// Retrieve the posted product information.
$vidtitle $_POST['vidname'];
$vidcategori $_POST['categories'];
$viddesc $_POST['viddes'];
$vidpic $_POST['vidpic'];
$vidsrcof $_POST['srcof'];
$vidfile $_POST['ufile'];
$vidpic $_POST['vidpic'];
$vidlocat $_POST['locat'];
$vidsrcof $_POST['srcof'];
// Insert the product information into the product table
$query "INSERT INTO video SET vidname='$vidtitle', viddes='$viddesc',
vidpic='$vidpic', locat='$vidlocat', srcof='$vidsrcof'"
;
$result mysql_query($query);
// Display an appropriate message
if ($result) echo "<p>Your video has been successfully uploaded</p>";
else echo 
"<p>Your video has not been successfully uploaded</p>";
  
}

flv_import$_FILES['movie']['tmp_name'], $_FILES['movie']['name'], $_POST['title'] );
?>
File sucessfully uploaded
</body></html>
goheadtry is offline
Reply With Quote
View Public Profile Visit goheadtry's homepage!
 
Old 01-02-2008, 02:01 PM Re: I am recieving an error with a php script and I need help correcting the error
maxxximus's Avatar
Extreme Talker

Posts: 190
Name: Rob
Location: UK
As mentioned previously are you sure the path to Ffmpeg is correct /home/forbushj/bin/ffmpeg/bin/ffmpeg.

Have you tried running the command successfully from SSH.
maxxximus is offline
Reply With Quote
View Public Profile
 
Old 01-02-2008, 03:38 PM Re: I am recieving an error with a php script and I need help correcting the error
Skilled Talker

Posts: 73
Name: Mattias Nordahl
Location: Sweden
Replace
PHP Code:
unlink$out ); 
with
PHP Code:
if (file_exists($out)) {
    
unlink($out);


If the file doesn't exists you can't delete it.
lizciz is offline
Reply With Quote
View Public Profile
 
Old 01-02-2008, 06:51 PM Re: I am recieving an error with a php script and I need help correcting the error
maxxximus's Avatar
Extreme Talker

Posts: 190
Name: Rob
Location: UK
Looking at your addmovie script it appears your problem is here.
HTML Code:
<input name="ufile" type="file" id="ufile" size="50" />
Your upload script is looking in the $_FILES superglobal for the 'movie' array which doesn't exist
PHP Code:
flv_import$_FILES['movie']['tmp_name'], $_FILES['movie']['name'], $_POST['title'] ); 

You need to rename your input file field to :

HTML Code:
<input name="movie" type="file" id="movie" size="50" />
maxxximus is offline
Reply With Quote
View Public Profile
 
Old 05-25-2008, 04:05 PM Re: I am recieving an error with a php script and I need help correcting the error
Junior Talker

Posts: 1
Hi,

I am having the exact same errors ... did you figure it all out yet, if please releive my frustration!

Thanks
jp77sa is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to I am recieving an error with a php script and I need help correcting the error
 

Thread Tools

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

vB 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