Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Olá, estou preciso adicionar os campos nome e mensagem referente a tabela tb_comentario e num_post na qual é uma chave estrangeira da tabela tb_blog onde estou recebendo atraves de um GET
testei as 2 maneiras
$chaveEstrangeira = $_GET['num_post'];
$sql = "INSERT INTO (tb_comentario (nome, mensagem, num_post) VALUES ('$nome', '$msg', $chaveEstrangeira))";
onde apresentou o seguinte erro:
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 '(tb_comentario (nome, mensagem, num_post) VALUES ('Thiago M', 'teste comentario'' at line 1
e esse:
$chaveEstrangeira = $_GET['num_post'];
$sql = "INSERT INTO tbl1_nome, tbl1.mensagem, tbl2.num_post
FROM tb_comentario as tbl1 INNER JOIN tb_blog as tbl2 ON tbl1.num_post = tbl2.num_post
WHERE tbl1.num_post = $chaveEstrangeira";
onde apresentou esse:
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 ' tbl1.mensagem, tbl2.num_post FROM tb_comentario as tbl1 INNER JOIN tb_blog a' at line 1
Carregando comentários...