Well, I'm trying to create a menu, and my sql is returning the following error: This is the result they are getting, I gave an echo to see if it was going correctly. Who we are is the name that identifies the menu, 2 is the code of who is the superior of it and 0 is which publication it is linked to. For min the error is in 0 because there is no publication so it assumes the value 0, but 0 is a valid value to be a menu id. Which is the right way to fix.
Quem Somos20
Cannot add or update a child row: a foreign key constraint fails ('jrcomunicacoes'.'tbl_MENU', CONSTRAINT 'FK00' FOREIGN KEY ('COD_PUBLI_VINCU') REFERENCES 'tbl_PUBLICACOES' ('COD_IDENT_PUBLI') ON DELETE NO ACTION ON UPDATE NO ACTION)
When I am sending to the bank I make a validation, where I take the field and equal it to zero, if true it returns null, if it is false I return the value of it, but it is not working. >
<div class="form-group">
<?php
$query = mysql_query("SELECT COD_IDENT_MENUX, TXT_DESCR_MENUX FROM tbl_MENU");
?>
<label>Superior:</label>
<select class="form-control" id="COD_IDENT_SUPER" name="COD_IDENT_SUPER" >
<option value="0" selected="selected">Menu Pai</option>
<?php while($menu = mysql_fetch_array($query)) { ?>
<option value="<?php echo $menu['COD_IDENT_MENUX'] ?>"><?php echo $menu['TXT_DESCR_MENUX'] ?></option>
<?php } ?>
</select>
</div>
My query is this:
$query = "INSERT INTO tbl_MENU (TXT_DESCR_MENUX, COD_IDENT_SUPER, COD_PUBLI_VINCU) VALUES";
$query .= "('$titulo','$pai','$publica')";
//executando a query
$inserir = mysql_query($query)