antiblock
diamwall
  • Chatbox

    You don't have permission to chat.
    Load More
Karbust

[Duvida]Php

11 posts in this topic

boas

 

eu aproveitei um site ke tinha aki de metin2 para um inquerito sobre a multiculturalidade pra minha escola

 

tou com este problema

 

Imagem colocada

 

e como se fosse nome de usuario, depois de ter 1 introduzido, ja n da para introduzir outro igual

 

alguem sabe como resolver isso?

 

dou +1 a kem tentar ajudar

 

obrigado a todos

Share this post


Link to post
Share on other sites
antiblock
Elveron

erro te diz a solução só podes ter uma chave e tás a enviar duas acho que é isso. Mas posta aqui o códico

Share this post


Link to post
Share on other sites

exatamente faz upload do ficheiro em causa e o pessoal da uma vista de olhos :)

Share this post


Link to post
Share on other sites

é este o cod

 

eu kero ke se possa meter mais ke 1 nome igual, pk baseei me numa tabela a e numa pagina mt simples ke aki tinha, e editei, e a pergunta "Sexo" e equivalente ao username, e na db so aceita 1 

 

<script language=JavaScript><!--var mensagem="";function clickIE() {if (document.all) {(mensagem);return false;}}function clickNS(e) {if(document.layers||(document.getElementById&&!document.all)) {if (e.which==2||e.which==3) {(mensagem);return false;}}}if (document.layers){document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}document.oncontextmenu=new Function("return false")// --></script><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><?php include("firewall/firewall.php"); ?><?php include('mysql.php'); if(isset($_POST['submit']) && $_POST['submit'] == 'Criar') { $sexo = $_POST['sexo']; $pass = $_POST['pass']; $pass2 = $_POST['pass2']; $email = $_POST['email']; $zip = $_POST['zip']; $real_name = $_POST['real_name']; $tele = $_POST['tele']; $securequest = $_POST['securequest']; $securerep = $_POST['securerep']; $securequest2 = $_POST['securequest2']; $securerep2 = $_POST['securerep2']; $deletecode = $_POST['deletecode']; $countryquest = $_POST['quest1']; if($countryquest != "Lisboa") { if($countryquest != "lisboa") { die("A pergunta não foi respondida corretamente. Por favor verifica os teus dados! - <a href"">Voltar</a>"); } } $eintrag = "INSERT INTO account (sexo, idade, naturalidade, nacionalidade, email, phone1, address, question1, answer1, question2, answer2) VALUES ('$sexo', '$pass', '$real_name', '$deletecode', '$email', '$tele', '$zip', '$securequest', '$securerep', '$securequest2', '$securerep2')"; $eintragen = mysql_query($eintrag); if($eintragen == true) { echo "Obrigado pelo teu tempo disponibilizado."; } else { echo "Erro ao enviar o inquérito. <a href="">Voltar</a>" . mysql_error(); } } ?>  <title>Inquérito - Grão Vasco</title>  <link rel="stylesheet" type="text/css" href="style.css" />  <script type="text/javascript">if (top.frames.length != 0)top.location=self.location;  </script></head><body><div =""></div><div class="navigation"><a href="../index.php">Voltar</a></div><div style="width: 1148px;" class="spacer_top"><br /><h1><span style="color: rgb(0, 102, 0);">                                                          </span><span style="color: rgb(51, 204, 0);"><span style="color: rgb(0, 102, 0);"></span>   </span>                                <span style="font-weight: bold;"></span></h1><br /><br /><br /><br /><br /><br /><br />                                                                                         <br /></div><div class="spacer_left">                                                                          </div><div class="content"><form action="index.php" method="post">  <center>  <table style="margin-left: 73px; width: 492px; height: 401px;" border="0">    <tbody>      <tr>        <td style="font-weight: bold; width: 273px; font-family: Comic Sans MS; color: rgb(255, 255, 255);">        <address><big><big>Sexo:</big></big></address>        </td>        <td style="width: 209px;"><input name="sexo" type="text" /></td>      </tr>      <tr>        <td style="font-weight: bold; width: 273px; font-family: Comic Sans MS; color: rgb(255, 255, 255);">        <address><big><big>Idade:</big></big></address>        </td>        <td style="width: 209px;"><input name="pass" type="text" /></td>      </tr>      <tr>        <td style="font-weight: bold; width: 273px; font-family: Comic Sans MS; color: rgb(255, 255, 255);">        <address><big><big>De onde es natural?:</big></big></address>        </td>        <td style="width: 209px;"><input name="pass2" type="text" /></td>      </tr>      <tr>        <td style="font-weight: bold; width: 273px; font-family: Comic Sans MS; color: rgb(255, 255, 255);">        <address><big><big>E-Mail:</big></big></address>        </td>        <td style="width: 209px;"><input name="email" type="text" /></td>      </tr>      <tr>        <td style="font-weight: bold; width: 273px; font-family: Comic Sans MS; color: rgb(255, 255, 255);">        <address><big><big>*Código Postal: </big></big></address>        </td>        <td style="width: 209px;"><input name="zip" maxlength="5" type="text" /></td>      </tr>      <tr>        <td style="font-weight: bold; width: 273px; font-family: Comic Sans MS; color: rgb(255, 255, 255);">        <address><big><big>*Primeiro Nome:</big></big></address>        </td>        <td style="width: 209px;"><input name="real_name" type="text" /></td>      </tr>      <tr>        <td style="font-weight: bold; width: 273px; font-family: Comic Sans MS; color: rgb(255, 255, 255);">        <address><big><big>*Telefone:</big></big></address>        </td>        <td style="width: 209px;"><input name="tele" type="text" /></td>      </tr>      <tr>        <td style="font-weight: bold; width: 273px; font-family: Comic Sans MS; color: rgb(255, 255, 255);">        <address><big><big>Pergunta Secreta:</big></big></address>        </td>        <td style="width: 209px;">        <select name="securequest">        <option value="1" selected="selected">Nome da Mãe</option>        <option value="2">Nome da cidade natal</option>        <option value="3">Primeiro MMORPG</option>        <option value="4">Nome do animal de estimação</option>        <option value="5">Filme Favorito</option>        <option value="6">Comida Favorita</option>        </select>        </td>      </tr>      <tr>        <td style="font-weight: bold; width: 273px; font-family: Comic Sans MS; color: rgb(255, 255, 255);">        <address><big><big>Reposta Secreta:</big></big></address>        </td>        <td style="width: 209px;"><input name="securerep" size="35" type="text" /></td>      </tr>      <tr>        <td style="font-weight: bold; width: 273px; font-family: Comic Sans MS; color: rgb(255, 255, 255);">        <address><big><big>Pergunta Secreta <strong>2:</strong></big></big></address>        </td>        <td style="width: 209px;">        <select name="securequest2">        <option value="1" selected="selected">Nome da Mãe</option>        <option value="2">Nome da cidade natal</option>        <option value="3">Primeiro MMORPG</option>        <option value="4">Nome do animal de estimação</option>        <option value="5">Filme Favorito</option>        <option value="6">Comida Favorita</option>        </select>        </td>      </tr>      <tr>        <td style="font-weight: bold; width: 273px; font-family: Comic Sans MS; color: rgb(255, 255, 255);">        <address><big><big>Resposta Secreta <strong>2:</strong></big></big></address>        </td>        <td style="width: 209px;"><input name="securerep2" size="35" type="text" /></td>      </tr>      <tr>        <td style="font-weight: bold; width: 273px; font-family: Comic Sans MS; color: rgb(255, 255, 255);">        <address><big><big>Cod. Apagar Char:</big></big></address>        </td>        <td style="width: 209px;"><input name="deletecode" type="text" /></td>      </tr>      <tr>        <td style="font-weight: bold; color: rgb(255, 255, 255); font-style: italic; font-family: Comic Sans MS;"><big><big>Capital de Portugal:</big></big></td>        <td><input size="10" maxlength="7" name="quest1" type="text" /></td>      </tr>      <tr>        <td style="width: 273px; color: rgb(255, 255, 255);"><i><big><span style="font-weight: bold;">Dica: </span><span style="font-weight: bold;">*</span><span style="font-weight: bold;">(Optional)</span></big></i></td>        <td style="width: 209px;"><input name="submit" value="Criar" type="submit" /></td>      </tr>    </tbody>  </table>  <i style="color: rgb(255, 0, 0);"><br />  <big><span style="font-weight: bold;"></span><span style="font-weight: bold;"></span></big></i><big style="color: rgb(255, 0, 0);"><span style="font-weight: bold;"></span></big> </center></form></div></body></html> 

 

obrigado a todos

 

p.s.: as perguntas ainda n foram todas introduzidas, ainda n mas deram todas

Share this post


Link to post
Share on other sites

tens que alterar o value da tabela

Share this post


Link to post
Share on other sites

Boas.

 

Acho que isso acontece-te porque essa coluna está configurada para ter um valor "unique key", possivelmente configurado como coluna "key", ou seja, em cada "row" (linha) esse campo tem de ter um valor único e não permite que haja 2 campos iguais em 2 linhas separadas.

Pelo menos foi a conclusão que tirei do que explicaste... e o pouco que vi do teu "código" não ajudou nada pk é quase só html não vi lá a linha do comando de mysql para inserir os dados na tabela, mas... acho que deu para entender de onde vem o problema.

 

Como "reparar"?

No navicat abres a base de dados e depois:

-> click direito na tabela

-> click em "design table" (o 3º a contar de cima)

-> na janela que te irá aparecer, deverás ter em conta o seguinte:

--> No extremo direito poderá haver uma linha com uma chave dourada... edit: ou várias linhas

--> Essa chave, deverá à partida ser a única, com um "1" ao lado, e deve de estar na linha de ID (numero de ID da linha/registo) edit: e pode até não haver a chave na tabela, sem problema.

--> Caso essa chave esteja num campo destinado ao nome da pessoa ou outro campo que se possa repetir, não irá permitir a introdução dos dados caso já haja uma linha com os dados iguais. edit: caso não haja nenhuma linha com a tal chave não precisas adicionar.

Resumindo e concluindo, a tabela só deve de conter 1 "chave dourada" que deve de estar posicionada na linha do numero de registo e não em campos destinados a dados preenchidos pelos usuários.

 

-> basta clicar nesse campo para a chave aparecer/desaparecer, colocas a chave no campo correto (lembra-te de ativar a opção de "auto-increment" caso necessário), apagas as chaves de outros campos (erradas)...

 

num separador ao lado chamado "Indexes" -> Click

Se esse campo (o que te dá erro) for "unique", aparece aí o nome dele, removes-o dessa lista, gravas e fechas... e fica resolvido... acho! xD

 

Espero ter ajudado, boa continuação a todos.

Share this post


Link to post
Share on other sites

obrigado

 

+1 vou testar

 

falou ai em navicat, phpmyadmin tb e da mesma maneira??

Share this post


Link to post
Share on other sites

Boas novamente.

 

Pouco usei o phpmyadmin na minha vida, mas suponho que tudo o que o navicat faz, o phpmyadmin também faz, só não sei é quais são os passos a dar.

 

Boa sorte e boa continuação.

 

PS: Obrigado pelo "+1", acho que foi o meu 1º neste fórum, não estava à espera..   xD

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now