PF2G Posted May 29, 2012 Share Posted May 29, 2012 hi i'm new at SQL so i'm working on a website where i add info and delete. The delete part i want a message box to confirm if i really want to delete the info: <!----------------------------------------------> <script type="text/JavaScript"> function confirmDelete() { var agree=confirm("Tem a certeza que quer remover?"); if (agree) { return true; } else { return false; } } </script> <!----------------------------------------------> In the add.php: <?PHP include 'db_connect.php'; $query_ident="SELECT * FROM content"; $ident=mysql_query($query_ident, $connect); $row_ident=mysql_fetch_assoc($ident); ?> <html> <head> <title>Administração - Adicionar</title> </head> <body style="color:#FFFFFF;" bgcolor="#666666"> <form action="" method="POST"> <table> <tr> <td align="right"> Identificador: </td> <td> <select name="identifier"> <?PHP do{ ?> <option value="<?PHP echo $row_ident['id_content']; ?>"> <!--selcciona opção definida--> <?PHP echo $row_ident['identifier']; ?> </option> <?PHP } while ($row_ident=mysql_fetch_assoc($ident)); ?> </select> </td> </tr> <tr height="10px"></tr> <tr> <td align="right"> Linguagem: </td> <td> <select name="lang"> <option value="1"> Português </option> <option value="2"> Inglês </option> </select> </td> </tr> <tr height="10px"></tr> <tr> <td align="right"> Título: </td> <td> <input type="text" name="titulo"> </input> </td> </tr> <tr height="10px"></tr> <tr> <td align="right" valign="top"> Conteúdo: </td> <td> <textarea name="descricao" cols="50" rows="10"></textarea> </td> </tr> <tr> <td></td> <td> <input type="submit" name="adicionar" value="Adicionar Informação" /> <a href="javascript:history.go(-1);"><input type="button" name="update" value="Voltar"/></a> </td> </tr> </table> </form> </body> </html> <?PHP /*************************************************/ if (isset($_POST['adicionar'])) { $identifier=$_POST['identifier']; $lang=$_POST['lang']; $titulo=$_POST['titulo']; $descricao=$_POST['descricao']; $sel_ident="SELECT * FROM content WHERE identifier='".$identifier."'"; $ident=mysql_query($sel_ident, $connect); $row_ident=mysql_fetch_assoc($ident); $sel_id="SELECT * FROM content_lang WHERE id_content='".$row_ident['id_content']."'"; $id=mysql_query($sel_id, $connect); $row_id=mysql_fetch_assoc($id); if($add_info=mysql_query("INSERT INTO content_lang (id_content, lang, titulo, descricao) VALUES ('".$row_id['id_content']."', '".$lang."', '".$titulo."', '".$descricao."')")) { echo 'Adicionado com sucesso.'; } else { echo 'Informação não foi inserida devido a um problema no sistema.'; } } ?> It gives me the second message, it means that the info wasn't inserted. Can someone help me? Quote Link to comment https://forums.phpfreaks.com/topic/263322-add-delete-sql/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.