mysql error

Web programming topics
Post Reply
Mysoogal
Captain
Captain
Posts: 223
Joined: Thu Dec 17, 2009 7:15 am
Location: Planet VPS

mysql error

Post by Mysoogal » Sun Dec 20, 2009 6:35 am

having problems with mysql and this code, i've messed up something in mysql but not really sure, when i visit list.php it says no video table im really lost

Code: Select all

<?php
  // encoding may take a few minutes.
  set_time_limit(1800);
  // disable output buffering so we can send the encoding progress to the browser.
  ob_implicit_flush(true);

  include("db.php");

  function StringToTime($Duration)
  {
      $TimeArray = NULL;
      if(strlen($Duration) > 0)
      {
          $TimeArray = explode(":", $Duration);                 if(count($TimeArray) > 2)
          {
              return ((int)$TimeArray[0]) * 3600 + ((int)$TimeArray[1]) * 60 + ((int)$TimeArray[2]);
          }
      }
  }
    function GetCurPath()
  {
      $curpath = $_SERVER["DOCUMENT_ROOT"].$_SERVER["PHP_SELF"];
      $index = strrpos($curpath, "/");
      if($index != 0)
          $curpath = substr($curpath, 0, $index);
      return $curpath;
  }       function flv_convert_get_thumb($FileName, $FileName_JPG, $FileName_FLV)
  {

flv_convert_get_thumb('$FileName', '$FileName_JPG', '$FileName_FLV,$in, $in_sub, $in_idx, $out_thumb, $out_vid');
// code provided and updated by steve of phpsnaps ! thanks
// accepts:
// 1: the input video file
// 2: path to thumb jpg
// 3: path to transcoded mpeg?
function flv_convert_get_thumb($in, $out_thumb, $out_vid)
{
  // get thumbnail
$cmd = ffmpeg -v 0 -y -i '.$FileName.' -vframes 1 -ss 250 -vcodec mjpeg -f rawvideo -s 286x160 -aspect 16:9 '.$$FileName_JPG;


  $res = shell_exec($cmd);
  // $res is the output of the command
 // transcode video
  $cmd = mencoder '.$FileName_FLV.' -o '.$FileName_FLV.' -sub '.$in_sub.' -subfont-text-scale 3.0 -subpos 99 -idx '.$in_idx.' -af volume=10 -aspect 16:9 -of avi -noodml -ovc x264 -x264encopts bitrate=500:level_idc=41:bframes=3:frameref=2: nopsnr: nossim: pass=1: threads=auto -oac mp3lame';

  $res = shell_exec($cmd);
}

?>

<?php
  $Author = $_REQUEST["author"];
  $Title = $_REQUEST["title"];
  $FileName = $_REQUEST["filename"];
  $Dimension = $_REQUEST["dimension"];

  // here removed blackmailing code and added yours
  $ExecResult = flv_convert_get_thumb($FileName, $FileName.'.jpg', $FileName.'.flv');
  // end of change

    // remove the uploaded file.
  unlink(GetCurPath() . "/files/".$FileName);
    if($ExecResult == 0)
  {
      $Conn = NULL;
      $Sql = NULL;
            $Conn = OpenDB();
      $time = date('Y-m-d H:i:s', time());

          $Duration = 0;
            $Sql = "INSERT INTO VIDEOS (AUTHOR, TITLE, DIMENSION, DURATION, ORIGINALFILE, FLVFILE, IMAGEFILE, UPLOADTIME, VIEWS) " .
       "VALUES ('".$Author."', '".$Title."', ".$Dimension.", ".$Duration.", '".$FileName."', '".$FileName.".flv', '".$FileName.".jpg', '".$time."', 1);";

        mysql_query($Sql);                     $err = mysql_error();
      mysql_close();
      if($err)
          echo "Error: " . $err . "<br>";

?>

<li><a href="list.php">Upload Finished ! Please Press Here</a></li>


this is error given to me
Error: Table 'fvec.VIDEOS' doesn't exist

Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /var/www/list.php on line 23
There are 0 videos in total

Upload my video now >>


--------------------------------------------------------------------------------

Error: Table 'fvec.VIDEOS' doesn't exist

what i'm i doing wrong here, is there missing video table in mysql ? i'm i passing the right info ? im confused as you can see i changed many things so im lost :cry:
Mysoogal
Captain
Captain
Posts: 223
Joined: Thu Dec 17, 2009 7:15 am
Location: Planet VPS

Re: mysql error

Post by Mysoogal » Sun Dec 20, 2009 6:41 am

this is dump of mysql

Code: Select all

-- Server version: 5.0.51
-- PHP Version: 5.2.4-2ubuntu5.9

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

--
-- Database: `fvec`
--

-- --------------------------------------------------------

--
-- Table structure for table `videos`
--

CREATE TABLE IF NOT EXISTS `videos` (
  `ID` int(10) unsigned NOT NULL auto_increment,
  `AUTHOR` varchar(255) default NULL,
  `TITLE` varchar(255) default NULL,
  `DIMENSION` int(11) default '0',
  `DURATION` int(11) default '0',
  `ORIGINALFILE` varchar(255) NOT NULL,
  `FLVFILE` varchar(255) NOT NULL,
  `IMAGEFILE` varchar(255) NOT NULL,
  `UPLOADTIME` date default NULL,
  `VIEWS` int(11) default '0',
  PRIMARY KEY  (`ID`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;

--
-- Dumping data for table `videos`
--

INSERT INTO `videos` (`ID`, `AUTHOR`, `TITLE`, `DIMENSION`, `DURATION`, `ORIGINALFILE`, `FLVFILE`, `IMAGEFILE`, `UPLOADTIME`, `VIEWS`) VALUES
(1, 'test', 'test', 1, 0, '{10DA4085-762F-90F2-35BA-C63BF1229B10}.mpeg', '{10DA4085-762F-90F2-35BA-C63BF1229B10}.mpeg.flv', '{10DA4085-762F-90F2-35BA-C63BF1229B10}.mpeg.jpg', '2009-06-17', 3),
(2, 'test', 'test', 1, 0, '{E7F7D8D1-3B97-FE8A-B440-1393A431BF76}.mpeg', '{E7F7D8D1-3B97-FE8A-B440-1393A431BF76}.mpeg.flv', '{E7F7D8D1-3B97-FE8A-B440-1393A431BF76}.mpeg.jpg', '2009-06-17', 3),
(3, 'sdf', 'sdfd', 1, 0, '{641BD967-5F5F-0B7D-B210-625D1EB70784}.mpeg', '{641BD967-5F5F-0B7D-B210-625D1EB70784}.mpeg.flv', '{641BD967-5F5F-0B7D-B210-625D1EB70784}.mpeg.jpg', '2009-06-17', 2),
(4, 'sdf', 'sdfd', 1, 0, '{641BD967-5F5F-0B7D-B210-625D1EB70784}.mpeg', '{641BD967-5F5F-0B7D-B210-625D1EB70784}.mpeg.flv', '{641BD967-5F5F-0B7D-B210-625D1EB70784}.mpeg.jpg', '2009-06-17', 3);
i dont think nothing is missing :shock:
User avatar
Neo
Site Admin
Site Admin
Posts: 2642
Joined: Wed Jul 15, 2009 2:07 am
Location: Colombo

Re: mysql error

Post by Neo » Mon Dec 21, 2009 11:49 am

There are some syntax errors. I'll point out the lines. (There can be more so you need to carefully check).

Line 27, 28:
1. Function call is out of the GetCurPath function
2. Doesn't end up with a semicolon
3. I think this function call is not required here?
4. The open bracket at Line 28 need to be removed I think

Code: Select all

  }       function flv_convert_get_thumb($FileName, $FileName_JPG, $FileName_FLV)
  {
Line 30:
1. Since $FileName, etc... are vaiabled, they must be passed without quotes.
2. I think this line also need to be commented?

Code: Select all

flv_convert_get_thumb('$FileName', '$FileName_JPG', '$FileName_FLV,$in, $in_sub, $in_idx, $out_thumb, $out_vid');
 
Line 39:
1. Missing quotes before ffmpeg.
2. At the end on line, there are two $ chars instead of one.

Code: Select all

$cmd = ffmpeg -v 0 -y -i '.$FileName.' -vframes 1 -ss 250 -vcodec mjpeg -f rawvideo -s 286x160 -aspect 16:9 .$$FileName_JPG;
 
Line 45:
1. Missing quotes before mencoder.
2. Invalid parameters. I don't see in_sub, in_idx are passed.

Code: Select all

$cmd = mencoder '.$FileName_FLV.' -o '.$FileName_FLV.' -sub '.$in_sub.' -subfont-text-scale 3.0 -subpos 99 -idx '.$in_idx.' -af volume=10 -aspect 16:9 -of avi -noodml -ovc x264 -x264encopts bitrate=500:level_idc=41:bframes=3:frameref=2: nopsnr: nossim: pass=1: threads=auto -oac mp3lame;
 
Line 59:
1. Is $FileName having just the name of the file? (ex: exampe)
In case it comes with the extension (Ex: example.avi), $FileName.'.jpg' will be example.avi.jpg

Code: Select all

$ExecResult = flv_convert_get_thumb($FileName, $FileName.'.jpg', $FileName.'.flv');
 
Finally, I can't see that you used mysql_connect function to connect to your database.
See this link.

I think you do not use a php editor with syntax highlighting. If you use 99% of these syntax error can be seen at the time of writing. Try Programmer's Notepad.
Mysoogal
Captain
Captain
Posts: 223
Joined: Thu Dec 17, 2009 7:15 am
Location: Planet VPS

Re: mysql error

Post by Mysoogal » Mon Dec 21, 2009 12:14 pm

thank you for point all those things out, i will try my best to fix it :D
Post Reply

Return to “Web programming”