Jump to content

Undentified problem PHP


Go to solution Solved by AbraCadaver,

Recommended Posts

Hello. I'm getting an error in my website when I pubish a new post:

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 ': Title','Subtitle' at line 1

 

 

 

I cannot identify the problem, as I don't changed anything before that occured... Additionally, the problem also occurs in MySQL in the same place

 

Publish PHP code:

<?php
 
if (isset($_POST["publish-p"]))
{
$categoria= mysql_real_escape_string($_POST['categoria']);
$categoria2= mysql_real_escape_string($_POST['categoria2']);
$destaque= mysql_real_escape_string($_POST['destaque']);
$publicado= mysql_real_escape_string($_POST['publicado']);
$news_title= mysql_real_escape_string($_POST['news_title']);
$news_subtitle= mysql_real_escape_string($_POST['news_subtitle']);
$news_desc= mysql_real_escape_string($_POST['news_desc']);
$news_post= mysql_real_escape_string($_POST['news_post']);
$news_date= mysql_real_escape_string($_POST['news_date']);
$hour= mysql_real_escape_string($_POST['hour']);
$news_image= mysql_real_escape_string($_POST['news_image']);
$news_image_peq= mysql_real_escape_string($_POST['news_image_peq']);
$publish="INSERT INTO news(categoria,categoria2,destaque,publicado,news_title,news_subtitle,news_desc,news_post,news_date,hour,news_image,news_image_peq) VALUES('$categoria','$categoria2','$destaque','$publicado',$news_title','$news_subtitle','$news_desc','$news_post','$news_date','$hour','$news_image','$news_image_peq')";
mysql_query($publish) OR DIE(mysql_error());
//mensagem após submeter dados
echo "<script>alert('Notícia publicada!');</script>";
 
}
 
?>
 
<!--CONTEUDO-->
<div class="row">
<div class="twelve columns">
 
<form action="#" method="post" onsubmit="return $(this).validate()" name="publish" >
 
<h3 class="n3">Publicar notícia</h3>
 
<div class="publish-content">
<div>
<h3 class="n3v4">Categoria</h3>
<select name="categoria">
<option value="Autos/Pistas">Autos/Pistas</option>
<option value="Autos/Ralis-TT">Autos/Ralis-TT</option>
<option value="Motos/Pistas">Motos/Pistas</option>
<option value="Motos/Ralis-TT">Motos/Ralis-TT</option>
<option value="Outros">Outros</option>
<option value="Entrevistas">Entrevistas</option>
</select>
</div>
<br/>
<div>
<h3 class="n3v4">Categoria 2 (opcional)</h3>
<select name="categoria2">
<option value="">Nenhuma</option>
<option value="Autos/Pistas">Autos/Pistas</option>
<option value="Autos/Ralis-TT">Autos/Ralis-TT</option>
<option value="Motos/Pistas">Motos/Pistas</option>
<option value="Motos/Ralis-TT">Motos/Ralis-TT</option>
<option value="Outros">Outros</option>
<option value="Entrevistas">Entrevistas</option>
</select>
</div>
<br/>
<h3 class="n3v4">Destaque?</h3>
<label class="cbox">
<input type="radio" name="destaque" value="sim" checked>Sim</input> 
<input type="radio" name="destaque" value="não">Não</input>
</label>
<br/>
<h3 class="n3v4">Publicar já?</h3>
<label class="cbox">
<input type="radio" name="publicado" value="sim" checked>Sim</input> 
<input type="radio" name="publicado" value="não">Não</input> 
</label>
<br/>
<input name="news_title" type="text" class="title" placeholder="(título)" data-validation="required" title="required"/>
<input name="news_subtitle" type="text" class="title" placeholder="(subtítulo)" data-validation="required" />
<input name="news_desc" type="text" class="description" placeholder="(descrição)" data-validation="required" title="required" maxlength="165"/>
<textarea name="news_post" type="text" class="post" placeholder="(notícia)" data-validation="required" title="required" ></textarea>
<input name="news_date" type="text" class="date" placeholder="(data)" data-validation="required" title="required" id="datepicker" />
<input name="hour" type="text" class="description" placeholder="(hora HH:MM)" data-validation="required" title="required" maxlength="5" data-format="hh:mm:ss" id="datetimepicker3" />
<input name="news_image" type="text" class="description" placeholder="(imagem homepage)" data-validation="required" title="required"/>
<input name="news_image_peq" type="text" class="description" placeholder="(imagem pequena)" data-validation="required" title="required"/></div>
 
<div class="publish-footer">
<input type="submit" name="publish-p" value="Publicar" class="button">
<input type="submit" name="cancel" value="Cancelar" class="secondary button" onclick="window.location='../login/?submit-news'" >
</div>
 
</form>
Edited by cdmafra
Link to comment
https://forums.phpfreaks.com/topic/282662-undentified-problem-php/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.