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
I need help with my php script. I think it is called error handling and control state
Old 10-09-2007, 09:56 PM I need help with my php script. I think it is called error handling and control state
goheadtry's Avatar
Webmaster Talker

Posts: 726
Name: John
Location: United States of America, California
Trades: 0
I want to finish my code so that it has ways of dealing with errors
Blue is if worked red is if there was an error
CODE IS INCLUDED

There is more than one thing that needs to be corrected by error handling in the same program

I first need my script to validate. If all the fields are filled in, and the upload file has an except able extension ("which the program checks in a text file which is located at http://www.technologyforever.com/goodfiles.txt with one extension without the do per line.

If successfully it needs to upload the file and go to the next step
If it fails because the extension is not allowed it needs to say "This format is not allowed", Or if it fails because not all fields are filled in. it needs to say "please complete the entire form" and try again

Then after uploading it needs to convert the video using the exec function in php with ffmpeg a command line video converter

If successfully converted go to next step and add information to the mysql database.
If it fails it needs to show the message that says "there was an error please contact support" and stop the script from continuing.

If it successful show a message that says "your video has been successfully added."
If it it has a problem writing to mysql database it needs to try to write to the database again, and if that fails just show a message that says please try again later.





PHP Code:
<?php

//upload video
$path"uploadvidd/".$HTTP_POST_FILES['ufile']['name'];
if(
$ufile !=none)
{
if (
file_exists($path)) {
$path"uploadvidd/1".$HTTP_POST_FILES['ufile']['name'];
}
if(
is_video($HTTP_POST_FILES['ufile']['tmp_name'])){

if(
copy($HTTP_POST_FILES['ufile']['tmp_name'], $path))
{
$input $_GET['input'];
list(
$usec$sec) = explode(' 'microtime());
$output str_replace('.''', (float)$usec + (float)$sec);



//video converter script for use on TechnologyForever.com which uses ffmpeg
//Do this if this part if upload is successful
$ffmpeg '/usr/bin/ffmpeg';//location of ffmpeg binary
$bitrate '32';//bitrate for audio options are 16,32,64
$ext '.flv';//Extension of output video files
$extb '.jpg';//Extension of image
$vidsize '320x240'//video size
$imgsize '150x100';//image size for menu
$force 'flv';//Force video format to
$sstime '00:00:35';//time to take screenshot
$samprate ='22050'// Sample rate choices are as follows 11025, 22050, 44100)
//Converts uploaded video with FFmpeg binary 
exec('$ffmpeg -i /home/forbushj/public_html/uploadvidd/'.$vidIN.' -ar $samprate -ab $bitrate -f flv -s $vidsize /home/forbushj/public_html/vidd/'.$vidout.'.$ext.');
//Creates an image from a frame at time given on $sstime
exec('$ffmpeg -i /home/forbushj/public_html/vidd/'.$vidout.''.$ext.' -s $imgsize -an -ss $sstime -an -r 1 -vframes 1 -y -f image2 /home/forbushj/public_html/pic/video/'.$vidout.'.$extb.');

IF 
this is successful I want it to write the information to a database if it is not successful I want to show an error message

//write to mysql
 
$linkID = @mysql_connect("HOST","USER ","PASSWORD") or die("Could not connect to MySQL server");
      @
mysql_select_db("forbushj_onetest") or die("Could not select database");
 
      
// Retrieve the posted product information.
      
$titlev stripslashes($_POST['vidname']);
      
$descrv stripslashes($_POST['viddes']);
$srcv stripslashes($_POST['srcof']);
$result mysql_query("
  INSERT INTO video
  (
    title,
    descr,
    pic,
    locat,
    src
  )
  VALUES
  (
    '" 
mysql_real_escape_string($titlev) . "',
    '" 
mysql_real_escape_string($descrv) . "',
    '" 
mysql_real_escape_string($output) . ".jpg',
    '" 
mysql_real_escape_string($output) . ".flv',
    '" 
mysql_real_escape_string($srcv) . "'
    )
"
);

?>
OLD CODE
PHP Code:

<?php 
$dsrptn 
'upload your videos to TechnologyForever.com'
$sect 'Videos';
$what 'Upload your videos';
include 
'head.php'?>

  
  <?php
//set where yzzou want to store files
//in this example we keep file in folder upload
//$HTTP_POST_FILES['ufile']['name']; = upload file name
//for example upload file name cartoon.gif . $path will be upload/cartoon.gif

//exec('ffmpeg -i /home/forbushj/public_html/'.$path.'  -s 150x100 -an -ss 00:00:35 -an -r 1 -vframes 1 -y -f image2 /home/forbushj/public_html/pic/video/'.$output.'.jpg');
$ext ".flv";
exec('ffmpeg -i /home/forbushj/public_html/'.$path.' -ar 22050 -ab 48 -f flv -s 320x240 /home/forbushj/public_html/vidd/'.$output.'.flv');
exec('ffmpeg -i /home/forbushj/public_html/vidd/'.$output.''.$ext.' -s 150x100 -an -ss 00:00:35 -an -r 1 -vframes 1 -y -f image2 /home/forbushj/public_html/pic/video/'.$output.'.jpg');
//exec('rm /home/forbushj/public_html/'.$path.'');
//passwords and users changed intentionally
 
$linkID = @mysql_connect("HOST","USER","PASSWORD") or die("Could not connect to MySQL server");
      @
mysql_select_db("forbushj_onetest") or die("Could not select database");
 
      
// Retrieve the posted product information.
      
$titlev stripslashes($_POST['vidname']);
      
$descrv stripslashes($_POST['viddes']);
$srcv stripslashes($_POST['srcof']);
$result mysql_query("
  INSERT INTO video
  (
    title,
    descr,
    pic,
    locat,
    src
  )
  VALUES
  (
    '" 
mysql_real_escape_string($titlev) . "',
    '" 
mysql_real_escape_string($descrv) . "',
    '" 
mysql_real_escape_string($output) . ".jpg',
    '" 
mysql_real_escape_string($output) . ".flv',
    '" 
mysql_real_escape_string($srcv) . "'
    )
"
);


 } else {
 
     } 
    }
}
function 
is_video$f ){
$result trim exec ('file -bi ' escapeshellarg $f ) ) ) ;
$TYPE explode("/"$result);
if(
$TYPE[0] == "video"){
return 
TRUE;
}
else{
return 
FALSE;
}
}


?>
<table width="95%" height="431" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
  <tr>
    <td width="10%"  colspan="3"><div align="center">
      <p>Your video should be upload if not please <a href="http://www.technologyforever.com/contact.html">contact us.</a></p>
      <p>&nbsp;</p>
      <p>Return to <a href="http://www.technologyforever.com/upload.php">video uploader</a></p>
      <p>Return to <a href="http://www.technologyforever.com/video1.html">video section</a></p>
      <p>Return to <a href="http://www.technologyforever.com">main page</a></p>
    </div></td>
</tr>
</table>
<?php include 'foot.php'?>
__________________
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; 10-10-2007 at 08:53 PM..
goheadtry is offline
Reply With Quote
View Public Profile Visit goheadtry's homepage!
 
 
Register now for full access!
Old 10-10-2007, 11:02 AM Re: I need help with my php script. I think it is called error handling and control s
rogem002's Avatar
PHP Chap

Posts: 843
Name: Mike
Location: United Kingdom
Trades: 0
Erm, do you think you could use some better grammar? I'm finding it very hard to understand what you mean.

You could try doing an fwrite() though:
http://uk.php.net/manual/en/function.fwrite.php
__________________
My Blog/Site:
Please login or register to view this content. Registration is FREE
rogem002 is offline
Reply With Quote
View Public Profile Visit rogem002's homepage!
 
Old 10-11-2007, 01:39 AM Re: I need help with my php script. I think it is called error handling and control s
goheadtry's Avatar
Webmaster Talker

Posts: 726
Name: John
Location: United States of America, California
Trades: 0
I fixed the post up a bit the grammar should be better, but I still need help.

Quote:
Originally Posted by rogem002 View Post
Erm, do you think you could use some better grammar? I'm finding it very hard to understand what you mean.

You could try doing an fwrite() though:
http://uk.php.net/manual/en/function.fwrite.php
__________________
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; 10-11-2007 at 11:51 PM..
goheadtry is offline
Reply With Quote
View Public Profile Visit goheadtry's homepage!
 
Reply     « Reply to I need help with my php script. I think it is called error handling and control state
 

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.35313 seconds with 12 queries