Ir para conteúdo
Fórum Script Brasil

Max Medeiros

Membros
  • Total de itens

    1
  • Registro em

  • Última visita

Sobre Max Medeiros

Max Medeiros's Achievements

0

Reputação

  1. Olá. Estou iniciando em php e mysql e quando fui testar o INSERT INTO ele simplesmente não funciona. Segue abaixo os códigos. index.php <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body bgcolor="#FFFFFF" text="#000000"> <table width="75%" border="0" cellpadding="1"> <tr> <td height="11"> <div align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><b> <a href="enviar.php"><img src="imagem/enviar.gif" width="71" height="18" border="0"></a></td> <td height="11"> <div align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><b> <a href="java script:self.print()"><img src="imagem/imprimir.gif" width="71" height="18" border="0"></a></td> </b></font> </table> <table width="75%" border="0" cellpadding="1"> <tr> <td height="11"> <p align="center"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><img src="imagem/fofocas2.gif" width="32" height="32"> No momento existem</font><font size="2"> </font><font size="1" face="Verdana, Arial, Helvetica, sans-serif"> <? $conexao = mysql_connect("localhost","root","123456"); $base = mysql_select_db("fofoca",$conexao); $comando = "select * from fofoca order by codigo desc"; $consulta = mysql_query($comando); $campo = mysql_fetch_array($consulta); echo mysql_num_rows($consulta); ?> fofocas cadastradas <img src="imagem/fofocas.gif" width="32" height="32"></font></p> </td> </tr> </table> <font size="2" face="Verdana, Arial, Helvetica, sans-serif"><b> </b></font></div> <table width="99%" border="0" cellpadding="1" height="28"> <tr> <td height="35">&nbsp; <table width="92%" border="1" cellpadding="1" height="58" bordercolor="#FFFFFF" bgcolor="#FFFFFF"> <?php $conexao = mysql_connect("localhost","root","123456"); $banco = mysql_select_db("fofoca"); ?> <?php $busca="select * from fofoca order by codigo desc"; ?> <?php $total_reg = "5"; // número de registros por página ?> <?php if (!isset($pagina) || (!$pagina)) { $pc = "1"; } else { $pc = $pagina; } ?> <?php $inicio = $pc - 1; $inicio = $inicio * $total_reg; ?> <?php $limite = mysql_query("$busca LIMIT $inicio,$total_reg"); $todos = mysql_query("$busca"); $tr = mysql_num_rows($todos); // verifica o número total de registros $tp = $tr / $total_reg; // verifica o número total de páginas // vamos criar a visualização while ($dados = mysql_fetch_array($limite)) { echo "<tr> <td bordercolor='#E1F8FF' bgcolor='#ECF5FF' height='18' valign='top' align='right' width='11%'> <font size='2' color='#003399' face='Verdana, Arial, Helvetica, sans-serif'><b> <img src='imagem/$dados[imagem].gif' width='32' height='32'></b></font> <font size='2' face='Verdana, Arial, Helvetica, sans-serif'></font> </td> <td bordercolor='#E1F8FF' bgcolor='#ECF5FF' height='18' valign='top' align='right' width='25%'> <div align='center'> <font size='2' color='#003399' face='Verdana, Arial, Helvetica, sans-serif'> <font color='#000000'>$dados[nick]</font></font> </div> </td> <td bordercolor='#E1F8FF' bgcolor='#ECF5FF' height='18' valign='top' align='left' width='64%'> <div align='center'> <font size='2' color='#990000' face='Verdana, Arial, Helvetica, sans-serif'>$dados[titulo]</font> </div> </td> </tr> <tr> <td bordercolor='#FFFFFF' bgcolor='#FFFFFF' height='6' valign='top' align='center' colspan='3'> <font size='2' color='#003399' face='Verdana, Arial, Helvetica, sans-serif'><font color='#000000'>$dados[fofoca]</font> </font></td> </tr> <tr> <td bordercolor='#FFFFFF' bgcolor='#FFFFFF' height='11' valign='top' align='center' colspan='3'> <p><font size='2' color='#003399' face='Verdana, Arial, Helvetica, sans-serif'><a href='mailto:$dados[email]'> <font color='#000099' size='1'><b>$dados[email]</b></font></a></font></p> </td> </tr> "; } ?> </table> <? // agora vamos criar os botões "Anterior e próximo" $anterior = $pc-1; $proximo = $pc+1; { if ($pc>1) <? { ?> <? echo ?> <a href='?pagina=$anterior'><img src="imagem/voltar.gif" width="71" height="18" border="0"></a> <? echo { ?> | <? } ?> <? } ?> <? if ($pc<$tr) ?> <? echo ?> <a href='?pagina=$proximo'> <img src="imagem/avançar.gif" width="71" height="18" border="0"></a> <? echo ?> <? { ?> <? } ?> <? } ?> </table> </body> </html> [/codebox] o segundo arquivo é o recebe.php [codebox] <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body bgcolor="#FFFFFF" text="#000000"> <? // $conn = mysql_connect("localhost","root","123456"); $conexao = mysql_connect ("localhost","root","123456"); //$banco = mysql_select_db("fofoca",$conn); $base=mysql_select_db("fofoca",$conn); $nick = $_POST["nick"]; $email = $_POST["email"]; $titulo = $_POST["titulo"]; $imagem = $_POST["imagem"]; $fofoca = $_POST["fofoca"]; $comando="insert into fofoca(nick,email,titulo,imagem,fofoca) values('$nick','$email','$titulo','$imagem','$fofoca')"; $consulta=mysql_query($comando); ?> <table width="99%" border="0" cellpadding="1" height="45"> <tr> <td height="19" bgcolor="#FFFFFF" bordercolor="#FFFFFF"> <div align="center"> <p><font size="2" face="Verdana, Arial, Helvetica, sans-serif" color="#000000">Sua fofoca foi incluida no sistema!</font></p> <p><font size="2" face="Verdana, Arial, Helvetica, sans-serif" color="#000000"><a href="index.php"> Click aqui para ver o seu post</a></font></p> </div> </td> </tr> </table> </body> </html> o terceiro é enviar.php <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body bgcolor="#FFFFFF" text="#000000"> <table width="99%" border="0" cellpadding="1" height="28"> <tr> <td height="35"> <table width="99%" border="0" cellpadding="1" height="28"> <tr> <td height="35"> <form action="recebe.php" method="POST"> <p align="center"><br> <b><font size="1" face="Verdana, Arial, Helvetica, sans-serif">Nick:<br> <input type="text" name="nick" size="10" maxlength="10"> <br> E-Mail:<br> <input type="text" name="email" size="30" maxlength="30"> <br> Titulo da fofoca<br> <input type="text" name="titulo" size="30" maxlength="30"> </font></b></p> <table width="36%" border="0" cellpadding="1" height="490" align="center"> <tr> <td width="42%" height="556"> <table width="70%" border="0" cellpadding="1" align="center" height="219"> <tr bordercolor="#FFFFFF"> <td width="18%" height="2">&nbsp; <input type = "radio" name="imagem" value = "1"> <br> </td> <td width="82%" height="2"><img src="imagem/imagem01.gif" width="32" height="32"></td> </tr> <tr bordercolor="#FFFFFF"> <td width="18%"> <input type = "radio" name="imagem" value = "2"> </td> <td width="82%"><img src="imagem/imagem02.gif" width="32" height="32"></td> </tr> <tr bordercolor="#FFFFFF"> <td width="18%"> <input type = "radio" name="imagem" value = "3"> </td> <td width="82%"><img src="imagem/imagem03.gif" width="32" height="32"></td> </tr> <tr bordercolor="#FFFFFF"> <td width="18%"> <input type = "radio" name="imagem" value = "4"> </td> <td width="82%"><img src="imagem/imagem04.gif" width="32" height="32"></td> </tr> <tr bordercolor="#FFFFFF"> <td width="18%"> <input type = "radio" name="imagem" value = "5"> </td> <td width="82%"><img src="imagem/imagem05.gif" width="32" height="32"></td> </tr> <tr bordercolor="#FFFFFF"> <td width="18%"> <input type = "radio" name="imagem" value = "6"> </td> <td width="82%"><img src="imagem/imagem06.gif" width="32" height="32"></td> </tr> <tr bordercolor="#FFFFFF"> <td width="18%"> <input type = "radio" name="imagem" value = "7"> </td> <td width="82%"><img src="imagem/imagem07.gif" width="32" height="32"></td> </tr> <tr bordercolor="#FFFFFF"> <td width="18%"> <input type = "radio" name="imagem" value = "8"> </td> <td width="82%"><img src="imagem/imagem08.gif" width="32" height="32"></td> </tr> <tr bordercolor="#FFFFFF"> <td width="18%"> <input type = "radio" name="imagem" value = "9"> </td> <td width="82%"><img src="imagem/imagem09.gif" width="32" height="32"></td> </tr> <tr bordercolor="#FFFFFF"> <td width="18%"> <input type = "radio" name="imagem" value = "10"> </td> <td width="82%"><img src="imagem/imagem10.gif" width="32" height="32"></td> </tr> </table> <table width="70%" border="0" cellpadding="1" align="center"> <tr bordercolor="#FFFFFF"> <td width="18%"> <input type = "radio" name="imagem" value = "11"> </td> <td width="82%"><img src="imagem/imagem11.gif" width="32" height="32"></td> </tr> <tr bordercolor="#FFFFFF"> <td width="18%"> <input type = "radio" name="imagem" value = "12"> </td> <td width="82%"><img src="imagem/imagem12.gif" width="32" height="32"></td> </tr> <tr bordercolor="#FFFFFF"> <td width="18%"> <input type = "radio" name="imagem" value = "13"> </td> <td width="82%"><img src="imagem/imagem13.gif" width="32" height="32"></td> </tr> <tr bordercolor="#FFFFFF"> <td width="18%"> <input type = "radio" name="imagem" value = "14"> </td> <td width="82%"><img src="imagem/imagem14.gif" width="32" height="32"></td> </tr> </table> </td> <td width="58%" height="556"> <table width="37%" border="0" cellpadding="1" align="center"> <tr bordercolor="#FFFFFF"> <td width="18%"> <input type = "radio" name="imagem" value = "15"> </td> <td width="82%"><img src="imagem/15.gif" width="32" height="32"></td> </tr> <tr bordercolor="#FFFFFF"> <td width="18%"> <input type = "radio" name="imagem" value = "16"> </td> <td width="82%"><img src="imagem/16.gif" width="32" height="32"></td> </tr> <tr bordercolor="#FFFFFF"> <td width="18%"> <input type = "radio" name="imagem" value = "17"> </td> <td width="82%"><img src="imagem/17.gif" width="32" height="32"></td> </tr> <tr bordercolor="#FFFFFF"> <td width="18%"> <input type = "radio" name="imagem" value = "18"> </td> <td width="82%"><img src="imagem/18.gif" width="32" height="32"></td> </tr> <tr bordercolor="#FFFFFF"> <td width="18%"> <input type = "radio" name="imagem" value = "19"> </td> <td width="82%"><img src="imagem/19.gif" width="32" height="32"></td> </tr> <tr bordercolor="#FFFFFF"> <td width="18%"> <input type = "radio" name="imagem" value = "20"> </td> <td width="82%"><img src="imagem/20.gif" width="32" height="32"></td> </tr> <tr bordercolor="#FFFFFF"> <td width="18%"> <input type = "radio" name="imagem" value = "21"> </td> <td width="82%"><img src="imagem/21.gif" width="32" height="32"></td> </tr> <tr bordercolor="#FFFFFF"> <td width="18%"> <input type = "radio" name="imagem" value = "22"> </td> <td width="82%"><img src="imagem/22.gif" width="32" height="32"></td> </tr> <tr bordercolor="#FFFFFF"> <td width="18%"> <input type = "radio" name="imagem" value = "23"> </td> <td width="82%"><img src="imagem/23.gif" width="32" height="32"></td> </tr> <tr bordercolor="#FFFFFF"> <td width="18%"> <input type = "radio" name="imagem" value = "24"> </td> <td width="82%"><img src="imagem/24.gif" width="32" height="32"></td> </tr> <tr bordercolor="#FFFFFF"> <td width="18%"> <input type = "radio" name="imagem" value = "25"> </td> <td width="82%"><img src="imagem/25.gif" width="32" height="32"></td> </tr> <tr bordercolor="#FFFFFF"> <td width="18%"> <input type = "radio" name="imagem" value = "26"> </td> <td width="82%"><img src="imagem/26.gif" width="32" height="32"></td> </tr> <tr bordercolor="#FFFFFF"> <td width="18%"> <input type = "radio" name="imagem" value = "27"> </td> <td width="82%"><img src="imagem/27.gif" width="32" height="32"></td> </tr> <tr bordercolor="#FFFFFF"> <td width="18%"> <input type = "radio" name="imagem" value = "28"> </td> <td width="82%"><img src="imagem/28.gif" width="32" height="32"></td> </tr> </table> </td> </tr> </table> <p align="center"><b><font size="1" face="Verdana, Arial, Helvetica, sans-serif">Digite aqui sua fofoca!<br> <textarea name="fofoca" rows="8" cols="50"></textarea> <br> <input type="submit" value="Enviar" name="submit"> <input type="reset" value="Limpar" name="reset"> <br> </font></b></p> </form> <b><font size="1" face="Verdana, Arial, Helvetica, sans-serif"> </font></b> </td> </tr> </table> </td> </tr> </table> <table width="99%" border="0" cellpadding="1" height="28"> <tr> <td height="35">&nbsp;</td> </tr> </table> </body> </html> [/codebox] e minha base de dados é a seguinte [codebox] fofoca ( codigo tinyint(3) NOT NULL auto_increment, nick char(20) default '0', email char(40) default '0', titulo char(200) default '0', imagem int(3) unsigned default '0', fofoca char(250) default '0', PRIMARY KEY (codigo) ) TYPE=MyISAM; podem me dizer ond eu estou errando? me ajudem pois isso é um problema que tenho que solucionar e não to vendo como. muito obrigado.
×
×
  • Criar Novo...