Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Bom dia pessoal estou com o seguinte problema
recebo um erro assim
"Você tem um erro de sintaxe no seu SQL próximo a '123456789', estado = 'RS' WHERE id = '50'' na linha 1"
e não consigo encontrar o erro ele ocorre na hora de clicar para editar o representante no caso
este é o código
<?php
if(isset($_POST['editar_repre']) && $_POST['editar_repre'] == 'edit'){
$id_editar = $_POST['id_repre'];
$representada = $_POST['representada'];
$contato = $_POST['contato'];
$email = $_POST['email'];
$telefone = $_POST['telefone'];
$estado = $_POST['estado'];
$cadastrar_repre = mysql_query("UPDATE silpa_repre SET representada = '$representada', contato = '$contato', email = '$email, telefone = '$telefone', estado = '$estado' WHERE id = '$id_editar'")
or die(mysql_error());
if($cadastrar_repre >= '1'){
echo "<div class=\"ok\">O representante foi cadastrado com sucesso!</div>";
}else{
echo "<div class=\"no\">Erro ao cadastrar o representante!</div>";
}
}
?>
<?php
$id_repre = $_POST['id_repre'];
$con_repre = mysql_query("SELECT id, representada, contato, email, telefone, estado FROM silpa_repre WHERE id ='$id_repre'")
or die(mysql_error());
if(@mysql_num_rows == '0'){
echo "Não encontramos representantes neste momento";//SE NÃO TIVER LINHAS NO BANCO A MENSAGEM APARECE
}else{
while($res_repre=mysql_fetch_array($con_repre)){//TRANSFORMA $NOTICIAS NUM ARRAY
$id_do_repre = $res_repre[0];
$representada = $res_repre[1];
$contato = $res_repre[2];
$email = $res_repre[3];
$telefone = $res_repre[4];
$estado = $res_repre[5];
?>
<form name="editar_repre" id="editar_repre" method="post" action="" enctype="multipart/form-data">
<fieldset>
<label>
<span>Estado</span>
<select name="estado" id="estado">
<option value="<?php echo $estado;?>"><?php echo strtoupper($estado);?></option>
<?php
$query = "SELECT sigla, descricao FROM estados ORDER BY descricao";
$result = mysql_query($query);
while ($rows = mysql_fetch_array($result)){
$sigla = $rows[0];
$estado = $rows[1];
?>
<option value="<?php echo $sigla;?>" id="<?php echo $sigla;?>"><?php echo strtoupper($estado);?></option>
<?php
}
?>
</select>
</label>
<label>
<span>Representada</span>
<input type="text" name="representada" value="<?php echo $representada;?>" />
</label>
<label>
<span>Contato</span>
<input type="text" name="contato" value="<?php echo $contato;?>" />
</label>
<label>
<span>Email</span>
<input type="text" name="email" value="<?php echo $email;?>" />
</label>
<label>
<span>Telefone</span>
<input type="text" name="telefone" value="<?php echo $telefone;?>" />
</label>
<input type="hidden" name="id_repre" value="<?php echo $id_repre;?>" />
<input type="hidden" name="editar_repre" value="edit" />
<input type="submit" value="Editar" name="Editar" class="cadastrar_btn" />
</fieldset>
</form>
<?php
}
}
?>Carregando comentários...