MySQL syntax error

1

Good morning, I have an error in my upload system. The error is as follows:

  

You have an error in your SQL syntax; check the manual that   correspond to your MySQL server version for the right syntax to use   near '', '845941', 'adventure', 'video / mp4', '28813678') 'at line 2

I have not been able to resolve until now, if anyone can help me, thank you. I'll leave the upload form code and the PHP file's code.

This is my upload form:

          <form role="form" method="post" action="inclusao.php" enctype="multipart/form-data">
          <div class="row">


              <div class="box box-success">
                <div class="box-header">
                  <h3 class="box-title">Filmes</h3>
                </div>
                <div class="box-body">

                  <!-- nome -->
                  <div class="form-group">
                    <label>Nome:</label>
                    <div class="input-group">
                      <div class="input-group-addon">
                        <i class="fa fa-tags"></i>
                      </div>
                      <input type="text" class="form-control" name="nome" placeholder="Nome Do filme"/>
                    </div><!-- /.input group -->
                  </div><!-- /.form group -->
                  <!-- nome -->

                  <!-- Date dd/mm/yyyy -->
                  <div class="form-group">
                    <label>Data:</label>
                    <div class="input-group">
                      <div class="input-group-addon">
                        <i class="fa fa-calendar"></i>
                      </div>
                      <input type="text" name="data" class="form-control"/>
                    </div><!-- /.input group -->
                  </div><!-- /.form group -->


                  <div class="form-group">
                    <label>Categorias:</label>
                    <div class="input-group">
                      <div class="input-group-addon">
                        <i class="fa fa-info"></i>
                      </div>
                     <select name="categoria" class="form-control">
                       <option></option>
                       <option value="acao">Ação</option>
                       <option value="animacao">Animação</option>
                       <option value="aventura">Aventura</option>
                       <option value="comedia">Comédia</option>
                       <option value="cromantica">Comédia Romântica</option>
                       <option value="corrida">Corrida</option>
                       <option value="classico">Clássicos</option>
                       <option value="documentario">Documentários</option>
                       <option value="drama">Drama</option>
                       <option value="faroeste">Faroeste</option>
                       <option value="ficcao">Ficção Científica</option>
                       <option value="guerra">Guerra</option>
                       <option value="herois">Herois</option>
                       <option value="infantil">Infantil</option>
                       <option value="luta">Lutas</option>
                       <option value="romance">Romance</option>
                       <option value="nacional">Nacional</option>
                       <option value="policial">Policial</option>
                       <option value="suspense">Suspense</option>
                       <option value="terror">Terror</option>
                     </select>
                    </div><!-- /.input group -->
                  </div><!-- /.form group -->
                  <div class="form-group">
                  <div class="input-group">
                      <div class="input-group-addon">
                        <i class="fa fa-info"></i>
                      </div>
                     <select name="categoria2" class="form-control">
                       <option></option>
                       <option value="acao">Ação</option>
                       <option value="animacao">Animação</option>
                       <option value="aventura">Aventura</option>
                       <option value="comedia">Comédia</option>
                       <option value="cromantica">Comédia Romântica</option>
                       <option value="corrida">Corrida</option>
                       <option value="classico">Clássicos</option>
                       <option value="documentario">Documentários</option>
                       <option value="drama">Drama</option>
                       <option value="faroeste">Faroeste</option>
                       <option value="ficcao">Ficção Científica</option>
                       <option value="guerra">Guerra</option>
                       <option value="herois">Herois</option>
                       <option value="infantil">Infantil</option>
                       <option value="luta">Lutas</option>
                       <option value="romance">Romance</option>
                       <option value="nacional">Nacional</option>
                       <option value="policial">Policial</option>
                       <option value="suspense">Suspense</option>
                       <option value="terror">Terror</option>
                     </select>
                    </div>
                    </div>
                  <!-- IP mask -->
                  <div class="form-group">
                    <label>Lancamento:</label>
                    <div class="input-group">
                      <div class="input-group-addon">
                        <i class="fa fa-laptop"></i>
                      </div>
                     <select name="lancar" class="form-control">
                       <option>Se O Filme For Um Lançamento Escolher A Opção Abaixo:</option>
                       <option value="lancamento">Lançamento</option>
                     </select>
                    </div><!-- /.input group -->
                  </div><!-- /.form group -->

                  <div class="form-group">
                    <label>Sinopse:</label>
                    <div class="input-group">
                      <div class="input-group-addon">
                        <i class="fa fa-edit"></i>
                      </div>
                      <textarea class="form-control" rows="3" name="sinopse" placeholder="Escreva a Sinopse do Filme"></textarea>
                    </div><!-- /.input group -->
                  </div><!-- /.form group -->
                <div class="form-group">
                    <label>Hora:</label>
                    <div class="input-group">
                      <div class="input-group-addon">
                        <i class="fa fa-clock-o"></i>
                      </div>
                      <input type="text" class="form-control" name="hora" placeholder="Hora do Filme Ex: 1hr40">
                    </div><!-- /.input group -->
                  </div><!-- /.form group -->
                <div class="form-group">
                    <label>Imagem:</label>
                    <div class="input-group">

                     <input type="file" name="img[]" multiple>
                    </div><!-- /.input group -->
                  </div><!-- /.form group -->
              <div class="form-group">
                    <label>Filme:</label>
                    <div class="input-group">

                      <input type="file" name="file[]" multiple>
                    </div><!-- /.input group -->
                  </div><!-- /.form group -->
                  <div class="box-footer">
                    <button type="submit" class="btn btn-primary" name="submit">Cadastrar</button>
                  </div>

                </div><!-- /.box-body -->
              </div><!-- /.box -->

</form>

And this is his action , the PHP page:

<?php

require"conexao.php";

if(isset($_POST['submit'])){    
//dados que serão incluidos
$nome=$_POST['nome'];
$data=$_POST['data'];
$categoria=$_POST['categoria'];
$categoria2=$_POST['categoria2'];
$lancar=$_POST['lancar'];
$sinopse=$_POST['sinopse'];
$hora = $_POST['hora'];

foreach($_FILES['img']['tmp_name'] as $key => $name_temp){
        $name = $_FILES['img']['name'] [$key];
        $tmpnm = $_FILES['img']['tmp_name'][$key];
        $type = $_FILES['img']['type'][$key];
        $size = $_FILES['img']['size'][$key];

        $dir = "images/capa/".$name;
        $mover = move_uploaded_file($tmpnm , $dir);

        foreach($_FILES['file']['tmp_name'] as $k => $n){
                $nomev = $_FILES['file']['name'] [$k];
                $t = $_FILES['file'] ['tmp_name'] [$k];
                $tipo = $_FILES['file']['type'][$k];
                $tam = $_FILES['file']['size'][$k];


        $dire = "video/".$nomev;
        $move = move_uploaded_file($t , $dire);

        if($mover&&$move){
            $sql = mysql_query("insert into filme(nome, categoria, img, lancamento, sinopse, hora, video, data, type, size, subcategoria, tipo, tam) values('$nome','$categoria','$name','$lancar','$sinopse','$hora'
                ,'$nomev','$data',$type','$size', '$categoria2', '$tipo', '$tam')") or die (mysql_error());
            if($sql){
                echo "Deu Certo";
            }
            else{
                echo "erro database";
            }
        }else{
            echo"nao nao";
        }
        }
    }
}

?>
    
asked by anonymous 31.08.2015 / 13:46

1 answer

1

Change this line:

 $sql = mysql_query("insert into filme(nome, categoria, img, lancamento, sinopse, hora, video, data, type, size, subcategoria, tipo, tam) values('$nome','$categoria','$name','$lancar','$sinopse','$hora'
                ,'$nomev','$data',$type','$size', '$categoria2', '$tipo', '$tam')") or die (mysql_error());

For this:

 $sql = mysql_query("insert into filme(nome, categoria, img, lancamento, sinopse, hora, video, data, type, size, subcategoria, tipo, tam) values('$nome','$categoria','$name','$lancar','$sinopse','$hora','$nomev','$data','$type','$size', '$categoria2', '$tipo', '$tam')") or die (mysql_error());

In this case, ' was missing to close the $ type. So the mistake. If it persists, do the following:

$sql = mysql_query("
                        INSERT INTO
                            filme
                        (
                            nome, 
                            categoria, 
                            img, 
                            lancamento, 
                            sinopse, 
                            hora, 
                            video, 
                            data, 
                            type, 
                            size, 
                            subcategoria, 
                            tipo, 
                            tam
                        )
                            VALUES
                        (
                            $nome,
                            $categoria,
                            $name,
                            $lancar,
                            $sinopse,
                            $hora,
                            $nomev,
                            $data,
                            $type,
                            $size,
                            $categoria2,
                            $tipo, 
                            $tam
                        )

");
    
31.08.2015 / 13:49