Help me on this error

Hi, can you help me please i am having problem in uploading the video.the length of my video is 5.88mb and the format is .ogv,when i am going to upload this it will message like this.

FAILED TO INSERTCannot add or update a child row: a foreign key constraint fails (uploadmovie.tbl_mname, CONSTRAINT tbl_mname_ibfk_1 FOREIGN KEY (mf_id) REFERENCES tbl_movie (id))

but when i am going to upload text file or some exe file like firefox,it will succesfully uploaded…i am confuse why it will not upload the movie.

I also check in the firebug and this is the error…

The character encoding of the HTML document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the page must to be declared in the document or in the transfer protocol.

can you help me please.Thank you in advance.

Are you trying to add a row to the table with a mf_id that doesn’t exist in the table the foreign key points to?

Hi, Thank you for the reply,This is how i created my table

but why is that if i will just upload word document it will successfully inserted and it wil save to my database.


<?php 
 $conn = mysql_connect('localhost','root','');
  
  if(!$conn)
   {
     die(mysql_error());
   }

  mysql_select_db('uploadmovie',$conn);
  
  $createTB = "create table if not exists tbl_movie(
                        id int not null auto_increment,
						video_file varchar(50),
						type longtext,
						size bigint,
						content blob,
						primary key(id))";
						
   if(mysql_query($createTB))
    {
	  echo "Table tbl_movie has been successfully created";
	}
  
 


   $createTB2 = "create table if not exists tbl_mname(
                  mn_id int not null auto_increment,
				  m_name varchar(30),
                  description varchar(50),
				  m_author varchar(30),
				  mf_id int,
				  primary key(mn_id),
				  foreign key (mf_id) references tbl_movie(id))";
				  
				  
	if(mysql_query($createTB2))
    {
	  echo "Table tbl_movie_name has been successfully created";
	}
  
   die(mysql_error());  			  
				  
                  				  
                                             
   
 ?>



And this is how i inserted…


<?php
   
     include_once("connectionDB.php");
	 
     function uploadMovie($video_F,
	                    $type,
						$size,
						$tmp_nme)
      {
	  
         $sql = "INSERT INTO tbl_movie values(default,'$video_F','$type','$size','$tmp_nme')";
		  
		 $res=mysql_query($sql);
		 
		 if (!$res)
		   return 'not succesfully inserted';
		 else  
		   return 'succesfully inserted';
		   
		 mysql_close();	    
      } 
	  
	  
	  function add($name,$description,$author)
	  {
	    $sql = "insert into tbl_mname values(default,
		                                     '$name',
											 '$description',
											 '$author',
											  LAST_INSERT_ID()
												  )";
												  
		  $result = mysql_query($sql);									  
	     if (!$result)
		   return ("FAILED TO INSERT".mysql_error());
		 else  
		   return 'succesfully inserted tbl_mname';
		   
	     mysql_close();	 
	  }
	  
?>





Please help me thank you in advance.

I don’t understand. If it works, what is the problem?

if it is a video,then it fails.

first thing you can do is check what LAST_INSERT_ID() is returing inside the function(if both queries are are running successfully)

I got the solution,it is in the php.ini the max_uploaded_size…i change it to bigger size,and now it’s working i can upload the movie file.