Ir para conteúdo

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Maycon Welliton

Erro de Sintaxe ao Inserir Cadastro

Recommended Posts

Olá, sou iniciante em programação html/php e estou desenvolvendo um sistema de cadastro, segue os códigos:

 

HTML:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3c.org/1999/xhtml" lang="en" xml : lang="en">
<html>
<head>	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
		<title>Ficha Inscrição</title>
		<!--endereço do jquery -->
		<script type="text/javascript" src="js/jquery.js"></script>
		<!--endereço do jquery -->
		
		<script type="text/javascript" src="js/jquery.maskedinput.js"/></script>
		<script type='text/javascript' src="js/cep.js"></script>

		<!--função abrir conteudo em div -->
		
		<!--folhas de estilo -->
		<style type="text/css" media="screen">
		@import "css/semtabelas.css";
		@import "css/simpletabs.css";
		</style>
		<!--folhas de estilo -->
		
</head>
<!--função abrir conteudo em div e mascaras-->

<script type="text/javascript">
		$(document).ready(function(){
			$("#menulateral a").click(function( e ){
				e.preventDefault();
				var href= $( this ).attr("href");
				$("#conteudo").load( href +" #conteudo");
		});
			
		
			
		</script>

		<script type="text/javascript">
		$(document).ready(function(){
		$("input.dataadmi").mask("99/99/9999");
		$("input.nascimento").mask("99/99/9999");
		$("input.cpf").mask("999.999.999-99");
		$("input.rg").mask("99.999.999-9");
		$("input.tel").mask("(99) 9999-9999");
		$("input.cel").mask("(99) 9999-9999");
		$("input.com").mask("(99) 9999-9999");
		});
		</script>
		
		
<body>	

<div id="tudo">	

	<div id="cabecalho">
			
		<h2 >Concurso CP-SMS_tmp 001-14</h2></span>

	</div> <!fecha cabecalho!>

	<div id="menulateral"> Menu lateral		
	
					<ul>
						<li><a href='index.html'><span>Pagina Principal</span></a></li>
						<li><a href='pesquisar.php'><span>Localizar Protocolo</span></a></li>
						<li><a href='menufuncionarios.php'><span>Nova Inscrição</span></a></li>
						<li><a href='menufuncionarios.php'><span>Listar Inscrições</span></a></li>
					</ul>  
	
	</div><!fecha menulateral!>
	
	<div id="conteudo">

<form method="POST" action="insere.php" >

<fieldset>
	<legend>Servidor</legend>

<label for="nome">Nome:</label>
	<input name="nome" type="text" id="nome" size="60"/>
	
	<label for="filhos">Sexo:</label>
	<select name="sexo" id="sexo">
		<option value="">--</option>
		<option value="Masculino">Masculino</option>
		<option value="Feminino">Feminino</option>
	</select>
	
	<label for="estadocivil">Estado Civil:</label>
		<select name="estadocivil" id="estadocivil">
		<option value="">--</option>
		<option value="Casado(a)">Casado(a)</option>
		<option value="Solteira(a)">Solteiro(a)</option>
		<option value="Divorciado(a)">Divorciado(a)</option>
		<option value="Viuvo(a)">Viuvo(a)</option>
	</select>
	
	<label for="filhos">Numero de Filhos:</label>
	<input type="int" name="filhos"  id="filhos" size="2"/>
	



<p>

<label for="cargo">Cargo:</label>
<input type="radio" name="cargo" value="Agente de Combate as Endemias" id="radio" checked="checked">Agente de Combate as Endemias

<input type="radio" name="cargo" value="Auxiliar de Consultorio Dentario" id="radio" >Auxiliar de Consultorio Dentario

<input type="radio" name="cargo" value="Auxiliar de Farmacia" id="radio"> Auxiliar de Consultorio Dentario

		
</fieldset>
<p>
<table>
		<tr>
		<td>
		<fieldset id="celula1"><legend>Doc. Pessoais</legend>
		
		<label for="rg">RG:</label>
		<input type="text" class="rg" id="rg" name="rg" size="10"/>
		
		<label for="emissor">Orgão Emissor:</label>
		<input type="text" class="emissor" id="emissor" name="emissor" size="5"/>
		
		<p>
		
		<label for="cpf">CPF:</label>
		<input type="text" class="cpf" id="cpf" name="cpf" size="12"/>
		
		
		<label for="nascimento">Data de Nascimento:</label>
		<input type="text" class="nascimento" id="nascimento" name="nascimento" size="8"/>
		
		<p>
		
		</fieldset>
		</td>
		
		<td>
		<fieldset id="celula1"><legend>Telefone</legend>
		
		<label for="tel">Residencial:</label>
		<input type="text" class="tel" id="tel" name="tel" size="13"/>
		
		<label for="cel">Celular:</label>
		<input type="text" class="tel" id="cel" name="cel" size="13"/><br /><br />
		
		<label for="rec">Recado:</label>
		<input type="text" class="tel" id="com" name="rec" size="13"/>
		
		</fieldset>	
		</td>
		</tr>
		</table>
		<p>
		
		<p>
		<fieldset><legend>Endereço</legend>
		    <label for="cep" float:"left">CEP (Somente numeros):</label>
            <input type="text" name="cep" id="cep" maxlength="8" />
 
             
            <label for="rua">Rua:</label>
            <input type="text" name="rua" id="rua" size="45" />
 
             
            <label for="numero">Numero:</label>
            <input type="text" name="numero" id="numero" size="5" />
 
            <p>
 
            <label for="bairro">Bairro:</label>
            <input type="text" name="bairro" id="bairro" size="25" />
 
            
            <label for="cidade">Cidade:</label>
            <input type="text" name="cidade" id="cidade" size="25" />
 
            
            <label for="estado">Estado:</label>
            <input type="text" name="estado" id="estado" size="2" />
		
            <br /><br />
 
		<p>
		</fieldset>
				
	<input type="submit" value=" Efetuar Incricao ">
	<input type="reset" name="resetar" id="resetar" value="Limpar Dados" />
	
	</form>
	
	</div><! fecha div=conteudo !>


	<div id="rodape">Rodape

	</div>


  
</div> <!fecha div=tudo !>

</body>

</html>

E o arquivo php para inserir no banco de dados:

<html>
<body>

<?php
include ("conectar.php");

$nome = $_POST['nome'];
$sexo = $_POST['sexo'];
$estadocivil = $_POST['estadocivil'];
$filhos = $_POST['filhos'];
$cargo = $_POST ['cargo'];
$rg = $_POST['rg'];
$emissor = $_POST['emissor'];
$cpf = $_POST['cpf'];
$nascimento = $_POST['nascimento'];
$tel = $_POST['tel'];
$cel = $_POST['cel'];
$rec = $_POST['rec'];
$cep = $_POST['cep'];
$rua = $_POST['rua'];
$numero = $_POST['numero'];
$bairro = $_POST['bairro'];
$cidade = $_POST['cidade'];
$estado = $_POST['estado'];
$sql = "INSERT INTO incricoes(

nome,
sexo,
estadocivil,
filhos,
cargo,
rg,
emissor,
cpf,
nascimento,
tel,
cel,
rec,
cep,
rua,
numero,
bairro,
cidade,
estado,
) 

VALUES (

'$nome',
'$sexo',
'$estadocivil',
'$filhos',
'$cargo',
'$rg',
'$emissor',
'$cpf',
'$nascimento',
'$tel',
'$cel',
'$rec',
'$cep',
'$rua',
'$numero',
'$bairro',
'$cidade',
'$estado',
)";

$cadastra = mysql_query($sql);
if($cadastra){
		echo "Inscricao efetuada com sucesso!";
		}
else 	{
		echo "Erro ao inserir inscricao!";
		<br />
		die(mysql_error());
		
		}
?>
</br>
<a href="index.html">Voltar!</a>;
</body>
</html>

está aparecendo esse erro:

 

Erro ao inserir inscricao!
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') VALUES ( 'maycon welliton da sillva', 'Masculino', 'Solteiro(a)', '0' at line 21

 

Acredito que o erro esteja nas <input type="radio">, porem não consegui encontra-lo, alguem consegue me ajudar com isso?

 

Att, Maycon.

Compartilhar este post


Link para o post
Compartilhar em outros sites

Pessoal, desculpem, encontrei o erro, estava aqui:

$sql = "INSERT INTO incricoes(nome,sexo,estadocivil,filhos,cargo,rg,emissor,cpf,nascimento,tel,cel,rec,cep,rua,numero,bairro,cidade,estado) 

tinha uma ,  a mais depois do estado.

Mas, obrigado.!!

mas se alguem conseguir otimiza-lo, estou aberto as sugestões....

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.