anacarine29 Posted June 13, 2012 at 01:42 PM Report Share #462479 Posted June 13, 2012 at 01:42 PM (edited) Boa tarde, estou a fazer um projecto e numa parte tenho um sistema de mensagens.Consigo enviar as mensagens para a base de dados e ter acesso aos dados da mesma, mas quando vou executar a parte de responder e tento ir buscar os dados atraves do id passado pela url , os dados não aparecem <table width="533" border="0" cellspacing="2" cellpadding="0"> <tr style="background:#666; color:#FFF; font:14px Verdana, Geneva, sans-serif; font-weight:bold"> <td width="100" align="center">Data:</td> <td width="400" align="center">Nome:</td> <td width="400" align="center">Email:</td> <td width="480" align="center">Executar:</td> </tr> <?php $idMensagem = $_GET['idMensagem']; $sql_msgAdmin = "SELECT * FROM mensagem WHERE idMensagem ='$idMensagem'" or die (mysql_error()); $res = mysql_query($sql_msgAdmin)or die(mysql_error()); while($row = mysql_fetch_assoc($res)) { $cor = 'style="background:#f4f4f4;"'; ?> <tr <?php echo $cor; ?> > <td align="center" width="300"><?php echo date ('d/m/Y H:i',strtotime($row['mensagemData']));?>h</td> <td align="center" width="400"><?php echo $row['mensagemNome'] ;?></td> <td align="center" width="400"><?php echo $row['mensagemEmail'];?></td> <td align="center" width="480"><a href="painel.php?exe=Mensagens/inbox">Voltar</a></td> </tr> <tr <?php echo $cor; ?> > <td align="center" width="100" style=" color:#666; font:14px Verdana, Geneva, sans-serif; font-weight:bold">Mensagem</td> <td align="center" width="400" colspan="3" style="font:12px Verdana, Geneva, sans-serif;" ><?php echo $row['mensagemMensagem'];?></td> </tr> <?php } echo (mysql_error()); ?> </table> A unica informação que me aparece na pagina é a primeira linha da tabela e não me aparece nenhum erro. Será que tenho alguma coisa mal no código que postei em cima? Por mais que olhe para o código não vejo nenhum erro Edited June 14, 2012 at 10:18 AM by brunoais geshi! Link to comment Share on other sites More sharing options...
HappyHippyHippo Posted June 13, 2012 at 01:45 PM Report Share #462481 Posted June 13, 2012 at 01:45 PM olha para esta linha ... isso tem aspecto de um copy-paste feito à presa $sql_msgAdmin = "SELECT * FROM mensagem WHERE idMensagem ='$idMensagem'" or die (mysql_error()); altera para $sql_msgAdmin = "SELECT * FROM mensagem WHERE idMensagem ='$idMensagem'"; já agora altera também esta $idMensagem = (int)$_GET['idMensagem']; IRC : sim, é algo que ainda existe >> #p@p Portugol Plus Link to comment Share on other sites More sharing options...
anacarine29 Posted June 13, 2012 at 02:06 PM Author Report Share #462497 Posted June 13, 2012 at 02:06 PM Olá HappyHippyHiippo, por acaso não foi nenhum copy paste, eu é que pus praticamente o mysql_error em tudo o que era "sitio" para ver se me apareciam erros, eu pouco percebo de programação, mas isso já são outros tantos. Fiz as alterações que aconselhaste, mas nao resolveu nada, continuo a ter o mesmo resultado 😞 Link to comment Share on other sites More sharing options...
HappyHippyHippo Posted June 13, 2012 at 04:44 PM Report Share #462532 Posted June 13, 2012 at 04:44 PM se não tens mensagem nenhuma de erro mesmo antes daquele código deverás ter a output de erros dasactivado adiciona as seguintes linhas à cabeça do script error_reporting(E_ALL); ini_set('display_errors', '1'); IRC : sim, é algo que ainda existe >> #p@p Portugol Plus Link to comment Share on other sites More sharing options...
anacarine29 Posted June 13, 2012 at 06:39 PM Author Report Share #462544 Posted June 13, 2012 at 06:39 PM aparece o seguinte erro: Notice: Undefined index: idMensagem in C:\wamp\www\Braguilectra Lda\admin\Mensagens\resposta.php on line 30 Não percebi, na url tenho http://localhost:8080/Braguilectra%20%20Lda/admin/painel.php?exe=Mensagens/resposta&idMensagem%20=20, na base de dados o nome da coluna está correcto idMensagem Link to comment Share on other sites More sharing options...
HappyHippyHippo Posted June 13, 2012 at 06:46 PM Report Share #462547 Posted June 13, 2012 at 06:46 PM so te posso responder a isso quando fizeres post do ficheiro resposta.php IRC : sim, é algo que ainda existe >> #p@p Portugol Plus Link to comment Share on other sites More sharing options...
anacarine29 Posted June 13, 2012 at 07:05 PM Author Report Share #462551 Posted June 13, 2012 at 07:05 PM (edited) o ficheiro resposta.php tem o seguinte código <?php include_once("sistema/restrito_all.php"); ?> <?php include_once("sistema/validar_utilizador.php");?> <?php include_once("header.php"); ?> <div id="local"> <div class="caminho">Onde estou : Braguilectra » Painel de Controlo » Visualizar/Responder</div><!--caminho--> <div class="welcome">Olá <?php echo $utilizadorNome ?>| Data <?php echo date('d/m/Y H:i').'h'; ?> |<a href="fim_sessao.php"> Terminar Sessão</a></div><!--welcome--> </div><!--local--> <div id="content"> <div class="inbox"> <?php include_once("menu.php"); ?> <div id="content_conteudo"> <?php include_once("sistema/loading.php"); ?> <div class="inbox"> <table width="533" border="0" cellspacing="2" cellpadding="0"> <tr style="background:#666; color:#FFF; font:14px Verdana, Geneva, sans-serif; font-weight:bold"> <td width="100" align="center">Data:</td> <td width="400" align="center">Nome:</td> <td width="400" align="center">Email:</td> <td width="480" align="center">Executar:</td> </tr> <?php error_reporting(E_ALL); ini_set('display_errors', '1'); $idMensagem = (int)$_GET['idMensagem'];<-------linha 30 $sql_msgAdmin = "SELECT * FROM mensagem WHERE idMensagem ='$idMensagem'"; $res = mysql_query($sql_msgAdmin)or die(mysql_error()); while($row = mysql_fetch_assoc($res)) { $cor = 'style="background:#f4f4f4;"'; ?> <tr <?php echo $cor; ?> > <td align="center" width="300"><?php echo date ('d/m/Y H:i',strtotime($row['mensagemData']));?>h</td> <td align="center" width="400"><?php echo $row['mensagemNome'] ;?></td> <td align="center" width="400"><?php echo $row['mensagemEmail'];?></td> <td align="center" width="480"><a href="painel.php?exe=Mensagens/inbox">Voltar</a></td> </tr> <tr <?php echo $cor; ?> > <td align="center" width="100" style=" color:#666; font:14px Verdana, Geneva, sans-serif; font-weight:bold">Mensagem</td> <td align="center" width="400" colspan="3" style="font:12px Verdana, Geneva, sans-serif;" ><?php echo $row['mensagemMensagem'];?></td> </tr> <?php } echo (mysql_error()); ?> </table> <<form name="respondeMensagem" action="" enctype="multipart/form-data" method="post"> <label> <textarea rows="8" cols="100" name="mensagem"><textarea> </label> <input type="submit" name="executar" id="executar" value="Enviar Resposta"/> </form> </div><!--inbox--> </div><!--content_conteudo--> </div><!--content--> <?php include_once("footer.php"); ?> A linha 30 é somente o código $idMensagem = (int)$_GET['idMensagem']; o code #ff000, fui eu que tentei por a linha a cor vermelho(sem sucesso) muito obrigado pela ajuda Happy, ja descobri o erro! Fiz um print do vetor e deu-me o seguinte Array ( [exe] => Mensagens/resposta [idMensagem_] => 20 ) alterei o $_GET[idMensagem'] para $_GET[idMensagem_'] e já deu 😉 Edited June 14, 2012 at 10:19 AM by brunoais geshi! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now