Eu tenho as seguintes tabelas no meu BD:
CREATE TABLE sistemas (
id int NOT NULL auto_increment,
nome varchar(30) NOT NULL default 'Indefinido',
tipo varchar(25) NOT NULL default 'Indefinido',
historia text(65535) NOT NULL,
imagem blob(65535) NOT NULL,
fabricante varchar(255) NOT NULL default 'Indefinido',
esptec varchar(255) NOT NULL default 'Indefinido',
PRIMARY KEY (id)
) TYPE=InnoDB;
CREATE TABLE emuladores (
id int NOT NULL auto_increment,
id_sistemas int NOT NULL,
nome varchar(255) NOT NULL default 'Indefinido',
site text(65535) NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY (id_sistemas) REFERENCES sistemas(id) ON DELETE CASCADE
) TYPE=InnoDB;
Pra incluir o emulador eu fiz o seguinte.
Populei uma combo com os sistemas:
<?php
$res = mysql_query("SELECT id, nome FROM sistemas");
while($registro = mysql_fetch_row($res))
{
$id_sist = $registro[0];
$nome_sist = $registro[1];
echo "<option value=\"$cod\">$nome_sist</option>\n";
}
?>
Fiz os outros 2 inputs pra pros outros campos e fiz a query:
$nome=$_POST["nome"];
$site=$_POST["site"];
$res = mysql_query("INSERT INTO emuladores (nome, site, id_sistemas)
VALUES ('$nome','$site',$id_sist)");
if(mysql_affected_rows()>0)
echo "<p align=\"center\">Emulador incluído com sucesso!</p>";
else {
$erro = mysql_error();
echo " <p align='center'>Erro:$erro</p>";
}
Os sistemas eu incluo beleza, mais quando eu vou incluir um emulador ele da o seguinte erro:
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 ')' at line 2
Não sei mais o que fazer, já tentei de tudo. O que pode ser isso?
Valew!!!