eduehi 0 Denunciar post Postado Janeiro 15, 2016 Bom dia Galera, o que será que estou errando aqui? $data = ''; $data = implode('-',array_reverse(explode('/',$_POST['data']))); if (App::$key) { $sql = "update comunicados set conteudo='" . $_POST["conteudo"] . "',titulo='" . $_POST["titulo"] . "',por='" . $_POST["por"] . "',cidade='" . $_POST["cidade"] . ",data=$data where id=" . App::$key; } else { $sql = "insert into comunicados (conteudo,titulo,por,data,cidade)values ( '" . $_POST["conteudo"] . "','" . $_POST["titulo"] . "', '" . $_POST["por"] . "','$data','" . $_POST["cidade"] . "')"; } $dados = Connection::exec($sql); No insert into, está funcionando corretamente. Mas no update dá o erro abaixo. Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 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 '',data=2016-08-18 where id=7' at line 1' Compartilhar este post Link para o post Compartilhar em outros sites
Beraldo 864 Denunciar post Postado Janeiro 15, 2016 Você não fechou as aspas simples do campo "cidade" Compartilhar este post Link para o post Compartilhar em outros sites
eduehi 0 Denunciar post Postado Janeiro 15, 2016 Verdade cara. Obrigado. Compartilhar este post Link para o post Compartilhar em outros sites