
breda
Membros-
Total de itens
3 -
Registro em
-
Última visita
Sobre breda

breda's Achievements
0
Reputação
-
Ola, a um tempo comprei o curso loja virtual completa do mjailton e por falta de tempo não fiz o curso ai agora comecei a fazer mas chego na parte de cadastro de produtos nada vai pra frente quando eu clico em inserir produto ele pede para eu selecionar a categoria ok depois a sub categoria ok ate ai ai aparece o formulario para preencher sobre o produto e quando clico em inserir ele leva para a pag op_produto e fica em branca e tb não manda nada para o banco a mesma coisa funciona para a função de alterar (somente a função excluir funciona) se eu inserir manualmente pelo banco ele lista os produtos vou postar o codigo se alguém puder me ajudar serei muito grato a tabela do banco produto esta assim id_produto id_categoria id_subcategoria produto foto descricao preço lancamento destaque A PAGINA LST_PRODUTO (que lista os produtos esta assim) <?php include "conexao.php";?> <!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> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td class="cat_cat"><div align="center"><strong>Lista geral de produtos </strong></div></td> </tr> <tr> <td><table width="100%" border="0" cellspacing="2" cellpadding="0"> <tr> <td width="8%" class="tarja"><strong>Código</strong></td> <td width="39%" align="center" class="tarja"><strong>Categoria/Subcategoria</strong></td> <td width="26%" align="center" class="tarja"><strong>Produto</strong></td> <td width="14%" align="center" class="tarja"><strong>Preço</strong></td> <td colspan="2" class="tarja"><div align="center"><strong>Ação</strong></div></td> </tr> <?php $sql = "SELECT p.*, c.*, s.* FROM produto p, categoria c, subcategoria s WHERE p.id_categoria = c.id_categoria and p.id_subcategoria = s.id_subcategoria ORDER BY p.produto"; $qry = mysql_query($sql); while ($linha = mysql_fetch_array($qry)){ ?> <tr> <td align="center" class="meio"><?php echo $linha[id_produto]; ?></td> <td class="meio"><?php echo $linha[categoria]."/".$linha[subcategoria]; ?></td> <td class="meio"><?php echo $linha[produto]; ?></td> <td align="center" class="meio"><?php echo $linha[preço]; ?></td> <td width="6%" align="center" class="meio"><a href="index.php?link=7&acao=Alterar&id=<?php echo $linha[id_produto]; ?>"><img src="img/mais.png" width="16" height="16" border="0" /></a></td> <td width="7%" align="center" class="meio"><a href="index.php?link=7&acao=Excluir&id=<?php echo $linha[id_produto]; ?>"><img src="img/deletar.png" width="16" height="16" border="0" /></a></td> </tr> <?php } ?> <tr> <td colspan="4"> </td> <td colspan="2"><div align="right"><a href="index.php?link=7"><img src="img/inserir.jpg" width="55" height="16" border="0" /></a></div></td> </tr> </table></td> </tr> <tr> <td> </td> </tr> </table> </body> </html> A PAGINA FRM_PRODUTO (Q TEM O FORMULARIO) esta assim <?php include "conexao.php"; $acao = $_GET["acao"]; $id = $_GET["id"]; $id_categoria = $_GET[id_categoria]; if ($acao != "") { $sql = "SELECT p.*, c.*, s.* FROM produto p, categoria c, subcategoria s WHERE p.id_categoria = c.id_categoria and p.id_subcategoria = s.id_subcategoria and p.id_produto = '$id' "; $qry = mysql_query($sql); $linha = mysql_fetch_array($qry); if ($_GET["consulta"] == "sim") { $id_categoria = $_GET[id_categoria]; } else { $id_categoria = $linha[id_categoria]; } $id_subcategoria = $linha[id_subcategoria]; $categoria = $linha[categoria]; $subcategoria = $linha[subcategoria]; $produto = $linha[produto]; $preço = $linha[preço]; $descricao = $linha[descricao]; $lancamento = $linha[lancamento]; $detaque = $linha[destaque]; $foto = $linha[foto]; } ?> <!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> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> <script type="text/javascript" src="jscripts/tiny_mce/tiny_mce.js"></script> <script type="text/javascript"> <!-- tinyMCE.init({ // General options mode : "textareas", theme : "advanced", plugins : "safari,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,imagemanager,filemanager", // Theme options theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect", theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor", theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen", theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak,|,insertfile,insertimage", theme_advanced_toolbar_location : "top", theme_advanced_toolbar_align : "left", theme_advanced_statusbar_location : "bottom", theme_advanced_resizing : true, // Example content CSS (should be your site CSS) content_css : "css/example.css", // Drop lists for link/image/media/template dialogs template_external_list_url : "js/template_list.js", external_link_list_url : "js/link_list.js", external_image_list_url : "js/image_list.js", media_external_list_url : "js/media_list.js", // Replace values for the template plugin template_replace_values : { username : "Some User", staffid : "991234" } }); function MM_jumpMenu(targ,selObj,restore){ //v3.0 eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'"); if (restore) selObj.selectedIndex=0; } //--> </script> <style type="text/css"> <!-- .style2 {font-size: 20px} --> </style> </head> <body> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td><div align="center"></div></td> </tr> <tr> <td><form action="op_produto.php" method="post" enctype="multipart/form-data" name="form1" id="form1"> <table width="54%" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td class="meio"><table width="403" border="0" align="center" cellpadding="2" cellspacing="0"> <tr> <td colspan="2" align="center" bgcolor="#CCCCCC"><span class="style2">Cadastro de Produto </span></td> </tr> <tr> <td width="83" bgcolor="#F5F5F5"><strong>Categoria</strong></td> <td width="314" bgcolor="#F5F5F5"><select name= "txt_idcategoria" id="txt_idcategoria" onchange="MM_jumpMenu('parent',this,0)"> <option></option> <?php $sql = "SELECT * FROM categoria ORDER BY categoria"; $qry = mysql_query($sql); while ($linha = mysql_fetch_array($qry)) {?> <option value ="index.php?link=7&acao=<?php echo $acao; ?>&consulta=sim&id_categoria=<?php echo $linha[id_categoria]; ?>&id=<?php echo $id; ?>"<?php if ($linha[id_categoria] == $id_categoria) echo "selected"; ?>><?php echo $linha[categoria]; ?> </option> <?php } ?> </select></td> </tr> <?php if ($id_categoria !="") {?> <tr> <td bgcolor="#F5F5F5"><strong>SubCategoria</strong></td> <td bgcolor="#F5F5F5"><label> <select name="txt_idsubcategoria" id="txt_idsubcategoria"> <option value="1"> Selecione a categoria </option> <?php $sql_subcat = "SELECT * FROM subcategoria WHERE id_categoria = '$id_categoria' ORDER BY subcategoria"; $qry_subcat = mysql_query($sql_subcat); while ($linha_subcat = mysql_fetch_array($qry_subcat)){ $valor = $linha_subcat[id_subcategoria]; if ($id_subcategoria == $valor) { $selecionado = "selected"; } else { $selecionado =""; } print "<option value = \"$valor\" $selecionado > $linha_subcat[subcategoria] </option>"; } ?> </select> </label></td> </tr> <tr> <td bgcolor="#F5F5F5"><strong>Produto</strong></td> <td bgcolor="#F5F5F5"><label> <input name="txt_produto" type="text" id="txt_produto" value="<?php echo $produto; ?>" size="50" /> </label></td> </tr> <tr> <td bgcolor="#F5F5F5"><strong>Foto</strong></td> <td bgcolor="#F5F5F5"><input name="txt_foto" type="text" id="txt_foto" value="<?php echo $foto; ?>" /></td> </tr> <tr> <td bgcolor="#F5F5F5"><strong>upload</strong></td> <td bgcolor="#F5F5F5"><input name="nome_arquivo" type="file" id="nome_arquivo" /></td> </tr> <tr> <td bgcolor="#F5F5F5"><strong>preço</strong></td> <td bgcolor="#F5F5F5"><label> <input name="txt_preco" type="text" id="txt_preco" value="<?php echo $preço; ?>" /> </label></td> </tr> <tr> <td bgcolor="#F5F5F5"><strong>Descrição</strong></td> <td bgcolor="#F5F5F5"><label> <textarea name="txt_descricao" cols="35" rows="6" id="txt_descricao"><?php echo $descricao; ?></textarea> </label></td> </tr> <tr> <td bgcolor="#F5F5F5"><strong>Lançamento</strong></td> <td bgcolor="#F5F5F5"><label> <select name="txt_lancamento" id="txt_lancamento"> <option value="S" <?php if($lancamento =="S") echo "selected"?>>Sim</option> <option value="N" <?php if($lancamento =="N") echo "selected"?>>Não</option> </select> </label></td> </tr> <tr> <td bgcolor="#F5F5F5"><strong>Destaque</strong></td> <td bgcolor="#F5F5F5"><label> <select name="txt_destaque" id="txt_destaque"> <option value="S" <?php if($destaque =="S") echo "selected"?>>Sim</option> <option value="N" <?php if($destaque =="N") echo "selected"?>>Não</option> </select> </label></td> </tr> <tr> <td bgcolor="#F5F5F5"> </td> <td bgcolor="#F5F5F5"> </td> </tr> <tr> <td colspan="2" bgcolor="#F5F5F5"><div align="center"> <input type="submit" name="Submit" value="<?php if ($acao !="") {echo $acao;} else { echo "Inserir";} ?>" /> <input name="acao" type="hidden" id="acao" value="<?php if ($acao !="") {echo $acao;} else { echo "Inserir";} ?>" /> <input name="id" type="hidden" id="id" value="<?php echo $id; ?>" /> <input name="txt_idcategoria" type="hidden" id="txt_idcategoria" value="<?php echo $id_categoria; ?>" /> </div></td> </tr> <?php } ?> </table></td> </tr> </table> </form> </td> </tr> <tr> <td> </td> </tr> </table> </body> </html> A pagina OP_PRODUTO esta assim <?php include "conexao.php"; $acao = $_POST["acao"]; $id = $_POST["id"]; $txt_subcategoria = $_POST["txt_subcategoria"]; $txt_idcategoria = $_POST["txt_idcategoria"]; $txt_id_subcategoria = $_POST["txt_idsubcategoria"]; $txt_categoria = $_POST["txt_categoria"]; $txt_subcategoria = $_POST["txt_subcategoria"]; $txt_produto = $_POST["txt_produto"]; $txt_foto = $_POST["txt_foto"]; $txt_destaque = $_POST["txt_destaque"]; $txt_preco = $_POST["txt_preco"]; $txt_descricao = $_POST["txt_descricao"]; $txt_lancamento = $_POST["txt_lancamento"]; if ( $acao=="Inserir" ) { //verifica a foto $arquivo = isset($_FILES["foto"]) ? $_FILES["foto"] : FALSE; $config = array(); $config["tamanho"] = 106883; $config["largura"] = 400; $config["altura"] = 250; $config["diretorio"] = "fotos/"; function nome($extensao) { global $config; $temp = substr(md5(uniqid(time())), 0, 10); $imagem_nome = $temp . "." . $extensao; if(file_exists($config["diretorio"] . $imagem_nome)) { $imagem_nome = nome($extensao); } return $imagem_nome; } if($arquivo) { $erro = array(); if(!eregi("^image\/(pjpeg|jpeg|png|gif|bmp)$", $arquivo["type"])) { $erro[] = "Arquivo em formato inválido! A imagem deve ser jpg, jpeg, bmp, gif ou png. Envie outro arquivo"; } else { if($arquivo["size"] > $config["tamanho"]) { $erro[] = "Arquivo em tamanho muito grande! A imagem deve ser de no máximo " . $config["tamanho"] . " bytes. Envie outro arquivo"; } $tamanhos = getimagesize($arquivo["tmp_name"]); if($tamanhos[0] > $config["largura"]) { $erro[] = "Largura da imagem não deve ultrapassar " . $config["largura"] . " pixels"; } if($tamanhos[1] > $config["altura"]) { $erro[] = "Altura da imagem não deve ultrapassar " . $config["altura"] . " pixels"; } } if(!sizeof($erro)) { preg_match("/\.(gif|bmp|png|jpg|jpeg){1}$/i", $arquivo["name"], $ext); $imagem_nome = nome($ext[1]); $imagem_dir = $config["diretorio"] . $imagem_nome; // Faz o upload da imagem move_uploaded_file($arquivo["tmp_name"], $imagem_dir); } elseif(sizeof($erro)) { echo "<tr><td colspan=2 bgcolor=red><B><U>Ocorreu(am) o(s) seguinte(s) erro(s):</u><BR>"; foreach($erro as $err) { echo " - " . $err . "<BR>"; } echo "</B></td></tr>"; } } //se der tudo certo if($arquivo && !sizeof($erro)) { $txt_foto = $imagem_nome; $sql = "INSERT INTO produto( id_categoria, id_subcategoria, produto, foto, descricao, destaque, preço, lancamento) VALUES ('$txt_idcategoria', '$txt_idsubcategoria', '$txt_produto', '$txt_foto', '$txt_descricao', '$txt_destaque', '$txt_preco', '$txt_lancamento')"; print $sql; mysql_query($sql) or die ("não foi possível inserir dados"); print "<script type = 'text/javascript'> location.href = 'index.php?link=6'</script>"; } } if ($acao==Alterar ) { $sql = "UPDATE produto SET id_categoria = '$txt_idcategoria', id_subcategoria = '$txt_idsubcategoria', produto = '$txt_produto', descricao = '$txt_descricao', destaque = '$txt_destaque', foto = '$txt_foto', preço = '$txt_preco', lancamento = '$txt_lancamento' WHERE id_produto = '$id' "; print($sql); mysql_query ($sql) or die ("não foi possível alterar os dados"); print "<script type = 'text/javascript'> location.href = 'index.php?link=6'</script>"; } if ($acao==Excluir) { $sql = "DELETE FROM produto WHERE id_produto = $id"; mysql_query($sql); print "<script type = 'text/javascript'> location.href = 'index.php?link=6'</script>"; } ?> se alguém puder me ajudar a resolver isso serei muito grato, pois ate onde eu sabia eu tentei mexer
-
Galera eu comprei o curso do Mjailton já faz um tempo e ate então não tinha parado para fazer pois estava sem tempo. Essa semana comecei a fazer estou seguindo conforme os videos, mas ao chegar na categoria de produtos so da pau no proprio video ele se embaralha então tentei resolver pesquisando alterando algumas coisas, mas como não sou bom em php e logica estou aprendendo não consegui resolver, (obs: vou colocar o codigo aqui, mas não sei se pode ou se vou coloca-lo de maneira correta, se eu errar, me perdoem) erro: ao clicar no botao inserir não insere nada no banco se eu inserir n o banco os dados e pedir para listar na pagina lst_produtos ele lista. so que se eu alterar ele não faz nada somente ta excluindo segue o codigo pagina lst_produto <?php include "conexao.php";?> <!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> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td class="cat_cat"><div align="center"><strong>Lista geral de produtos </strong></div></td> </tr> <tr> <td><table width="100%" border="0" cellspacing="2" cellpadding="0"> <tr> <td width="8%" class="tarja"><strong>Código</strong></td> <td width="39%" align="center" class="tarja"><strong>Categoria/Subcategoria</strong></td> <td width="26%" align="center" class="tarja"><strong>Produto</strong></td> <td width="14%" align="center" class="tarja"><strong>Preço</strong></td> <td colspan="2" class="tarja"><div align="center"><strong>Ação</strong></div></td> </tr> <?php $sql = "SELECT p.*, c.*, s.* FROM produto p, categoria c, subcategoria s WHERE p.id_categoria = c.id_categoria and p.id_subcategoria = s.id_subcategoria ORDER BY p.produto"; //echo $sql; $qry = mysql_query($sql); while ($linha = mysql_fetch_array($qry)){ ?> <tr> <td align="center" class="meio"><?php echo $linha[id_produto]; ?></td> <td class=meio"><?php echo $linha[categoria]."/".$linha[subcategoria]; ?></td> <td class="meio"><?php echo $linha[produto]; ?></td> <td align="center" class="meio"><?php echo $linha[preço]; ?></td> <td width="6%" align="center" class="meio"><a href="index.php?link=7&acao=Alterar&id=<?php echo $linha[id_produto]; ?>"><img src="img/mais.png" width="16" height="16" border="0" /></a></td> <td width="7%" align="center" class="meio"><a href="index.php?link=7&acao=Excluir&id=<?php echo $linha[id_produto]; ?>"><img src="img/deletar.png" width="16" height="16" border="0" /></a></td> </tr> <?php } ?> <tr> <td colspan="4"> </td> <td colspan="2"><div align="right"><a href="index.php?link=7"><img src="img/inserir.jpg" width="55" height="16" border="0" /></a></div></td> </tr> </table></td> </tr> <tr> <td> </td> </tr> </table> </body> </html> Página FRM_PRODUTO <?php include "conexao.php"; $acao = $_GET["acao]; $id = $_GET["id"]; $id_categoria = $_GET[id_categoria]; if ($acao != "") { $sql = "SELECT p.*, c.*, s.* FROM produto p, categoria c, subcategoria s WHERE p.id_categoria = c.id_categoria and p.id_subcategoria = s.id_subcategoria and p.id_produto = '$id' "; $qry = mysql_query($sql); $linha = mysql_fetch_array($qry); if ($_GET["consulta"] == "sim") { $id_categoria = $_GET[id_categoria]; } else { $id_categoria = $linha[id_categoria]; } $id_subcategoria = $linha[id_subcategoria]; $categoria = $linha[categoria]; $subcategoria = $linha[subcategoria]; $produto = $linha[produto]; $preço = $linha[preço]; $descricao = $linha[descricao]; $lancamento = $linha[lancamento]; $detaque = $linha[destaque]; $foto = $linha[foto]; } ?> <!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> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> <script type="text/javascript" src="jscripts/tiny_mce/tiny_mce.js"></script> <script type="text/javascript"> <!-- tinyMCE.init({ // General options mode : "textareas", theme : "advanced", plugins : "safari,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,imagemanager,filemanager", // Theme options theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect", theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor", theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen", theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak,|,insertfile,insertimage", theme_advanced_toolbar_location : "top", theme_advanced_toolbar_align : "left", theme_advanced_statusbar_location : "bottom", theme_advanced_resizing : true, // Example content CSS (should be your site CSS) content_css : "css/example.css", // Drop lists for link/image/media/template dialogs template_external_list_url : "js/template_list.js", external_link_list_url : "js/link_list.js", external_image_list_url : "js/image_list.js", media_external_list_url : "js/media_list.js", // Replace values for the template plugin template_replace_values : { username : "Some User", staffid : "991234" } }); function MM_jumpMenu(targ,selObj,restore){ //v3.0 eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'"); if (restore) selObj.selectedIndex=0; } //--> </script> <style type="text/css"> <!-- .style2 {font-size: 20px} --> </style> </head> <body> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td><div align="center"></div></td> </tr> <tr> <td><form action="op_produto.php" method="post" enctype="multipart/form-data" name="form1" id="form1"> <table width="54%" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td class="meio"><table width="403" border="0" align="center" cellpadding="2" cellspacing="0"> <tr> <td colspan="2" align="center" bgcolor="#CCCCCC"><span class="style2">Cadastro de Produto </span></td> </tr> <tr> <td width="83" bgcolor="#F5F5F5"><strong>Categoria</strong></td> <td width="314" bgcolor="#F5F5F5"><select name= "txt_idcategoria" id="txt_idcategoria" onchange="MM_jumpMenu('parent',this,0)"> <option></option> <?php $sql = "SELECT * FROM categoria ORDER BY categoria"; $qry = mysql_query($sql); while ($linha = mysql_fetch_array($qry)) {?> <option value ="index.php?link=7&acao=<?php echo $acao; ?>&consulta=sim&id_categoria=<?php echo $linha[id_categoria]; ?>&id=<?php echo $id; ?>"<?php if ($linha[id_categoria] == $id_categoria) echo "selected"; ?>><?php echo $linha[categoria]; ?> </option> <?php } ?> </select></td> </tr> <?php if ($id_categoria !="") {?> <tr> <td bgcolor="#F5F5F5"><strong>SubCategoria</strong></td> <td bgcolor="#F5F5F5"><label> <select name="txt_idsubcategoria" id="txt_idsubcategoria"> <option value="1"> Selecione a categoria </option> <?php $sql_subcat = "SELECT * FROM subcategoria WHERE id_categoria = '$id_categoria' ORDER BY subcategoria"; $qry_subcat = mysql_query($sql_subcat); while ($linha_subcat = mysql_fetch_array($qry_subcat)){ $valor = $linha_subcat[id_subcategoria]; if ($id_subcategoria == $valor) { $selecionado = "selected"; } else { $selecionado =""; } print "<option value = \"$valor\" $selecionado > $linha_subcat[subcategoria] </option>"; } ?> </select> </label></td> </tr> <tr> <td bgcolor="#F5F5F5"><strong>Produto</strong></td> <td bgcolor="#F5F5F5"><label> <input name="txt_produto" type="text" id="txt_produto" value="<?php echo $produto; ?>" size="50" /> </label></td> </tr> <tr> <td bgcolor="#F5F5F5"><strong>Foto</strong></td> <td bgcolor="#F5F5F5"><input name="txt_foto" type="text" id="txt_foto" value="<?php echo $foto; ?>" /></td> </tr> <tr> <td bgcolor="#F5F5F5"><strong>upload</strong></td> <td bgcolor="#F5F5F5"><input name="nome_arquivo" type="file" id="nome_arquivo" /></td> </tr> <tr> <td bgcolor="#F5F5F5"><strong>preço</strong></td> <td bgcolor="#F5F5F5"><label> <input name="txt_preco" type="text" id="txt_preco" value="<?php echo $preço; ?>" /> </label></td> </tr> <tr> <td bgcolor="#F5F5F5"><strong>Descrição</strong></td> <td bgcolor="#F5F5F5"><label> <textarea name="txt_descricao" cols="35" rows="6" id="txt_descricao"><?php echo $descricao; ?></textarea> </label></td> </tr> <tr> <td bgcolor="#F5F5F5"><strong>Lançamento</strong></td> <td bgcolor="#F5F5F5"><label> <select name="txt_lancamento" id="txt_lancamento"> <option value="S" <?php if($lancamento =="S") echo "selected"?>>Sim</option> <option value="N" <?php if($lancamento =="N") echo "selected"?>>Não</option> </select> </label></td> </tr> <tr> <td bgcolor="#F5F5F5"><strong>Destaque</strong></td> <td bgcolor="#F5F5F5"><label> <select name="txt_destaque" id="txt_destaque"> <option value="S" <?php if($destaque =="S") echo "selected"?>>Sim</option> <option value="N" <?php if($destaque =="N") echo "selected"?>>Não</option> </select> </label></td> </tr> <tr> <td bgcolor="#F5F5F5"> </td> <td bgcolor="#F5F5F5"> </td> </tr> <tr> <td colspan="2" bgcolor="#F5F5F5"><div align="center"> <input type="submit" name="Submit" value="<?php if ($acao !="") {echo $acao;} else { echo "Inserir";} ?>" /> <input name="acao" type="hidden" id="acao" value="<?php if ($acao !="") {echo $acao;} else { echo "Inserir";} ?>" /> <input name="id" type="hidden" id="id" value="<?php echo $id; ?>" /> <input name="txt_idcategoria" type="hidden" id="txt_idcategoria" value="<?php echo $id_categoria; ?>" /> </div></td> </tr> <?php } ?> </table></td> </tr> </table> </form> </td> </tr> <tr> <td> </td> </tr> </table> </body> </html> Página OP_PRODUTO <?php include "conexao.php"; $acao = $_POST["acao"]; $id = $_POST["id"]; $txt_subcategoria = $_POST["txt_subcategoria"]; $txt_idcategoria = $_POST["txt_idcategoria"]; $txt_id_subcategoria = $_POST["txt_idsubcategoria"]; $txt_categoria = $_POST["txt_categoria"]; $txt_subcategoria = $_POST["txt_subcategoria"]; $txt_produto = $_POST["txt_produto"]; $txt_foto = $_POST["txt_foto"]; $txt_destaque = $_POST["txt_destaque"]; $txt_preco = $_POST["txt_preco"]; $txt_descricao = $_POST["txt_descricao"]; $txt_lancamento = $_POST["txt_lancamento"]; if ( $acao==Inserir" ) { //verifica a foto $arquivo = isset($_FILES["foto]) ? $_FILES["foto"] : FALSE; $config = array(); $config["tamanho"] = 106883; $config["largura"] = 400; $config["altura"] = 250; $config["diretorio"] = "fotos/"; function nome($extensao) { global $config; $temp = substr(md5(uniqid(time())), 0, 10); $imagem_nome = $temp . "." . $extensao; if(file_exists($config["diretorio"] . $imagem_nome)) { $imagem_nome = nome($extensao); } return $imagem_nome; } if($arquivo) { $erro = array(); if(!eregi("^image\/(pjpeg|jpeg|png|gif|bmp)$", $arquivo["type"])) { $erro[] = "Arquivo em formato inválido! A imagem deve ser jpg, jpeg, bmp, gif ou png. Envie outro arquivo"; } else { if($arquivo["size"] > $config["tamanho"]) { $erro[] = "Arquivo em tamanho muito grande! A imagem deve ser de no máximo " . $config["tamanho"] . " bytes. Envie outro arquivo"; } $tamanhos = getimagesize($arquivo["tmp_name"]); if($tamanhos[0] > $config["largura"]) { $erro[] = "Largura da imagem não deve ultrapassar " . $config["largura"] . " pixels"; } if($tamanhos[1] > $config["altura"]) { $erro[] = "Altura da imagem não deve ultrapassar " . $config["altura"] . " pixels"; } } if(!sizeof($erro)) { preg_match("/\.(gif|bmp|png|jpg|jpeg){1}$/i", $arquivo["name"], $ext); $imagem_nome = nome($ext[1]); $imagem_dir = $config["diretorio"] . $imagem_nome; // Faz o upload da imagem move_uploaded_file($arquivo["tmp_name"], $imagem_dir); } elseif(sizeof($erro)) { echo "<tr><td colspan=2 bgcolor=red><B><U>Ocorreu(am) o(s) seguinte(s) erro(s):</u><BR>"; foreach($erro as $err) { echo " - " . $err . "<BR>"; } echo "</B></td></tr>"; } } //se der tudo certo if($arquivo && !sizeof($erro)) { $txt_foto = $imagem_nome; $sql = "INSERT INTO produto ( id_categoria, id_subcategoria, produto, foto, descricao, destaque, preço, lancamento) VALUES ('$txt_idcategoria', '$txt_idsubcategoria', '$txt_produto', '$txt_foto', '$txt_descricao', '$txt_destaque', '$txt_preco', '$txt_lancamento')"; print $sql; mysql_query($sql) or die ("não foi possível inserir dados"); print "<script type = 'text/javascript'> location.href = 'index.php?link=6'</script>"; } } if ($acao==Alterar ) { $sql = "UPDATE produto SET id_categoria = '$txt_idcategoria', id_subcategoria = '$txt_idsubcategoria', produto = '$txt_produto', descricao = '$txt_descricao', destaque = '$txt_destaque', foto = '$txt_foto', preço = '$txt_preco', lancamento = '$txt_lancamento' WHERE id_produto = '$id' "; print($sql); mysql_query ($sql) or die ("não foi possível alterar os dados"); print "<script type = 'text/javascript'> location.href = 'index.php?link=6'</script>"; } if ($acao==Excluir) { $sql = "DELETE FROM produto WHERE id_produto = $id"; mysql_query($sql); print "<script type = 'text/javascript'> location.href = 'index.php?link=6'</script>"; } ?> se alguém puder me ajudar serei muito grato lembrando que o link de redirecionamento index.php?link=6 esta correto caso alguém pergunte
-
Ola galera, estava montando umas paginas para uma amiga e ate então o site estava pronto funcionando td peguei desliguei a maquina e no dia seguinte ela pediu para eu colocar mais uns links pra ela (coleção) masculina e feminina ai eu criei o banco td certinho não deu erro fui no insert form wizard da barra develooper como estava fazendo ate então e o formulario foi criado sem erros, so que quando eu fui vizualizar deu esse erro conforme descrição a baixo. (os arquivos que eu tinha feito da mesma maneira estao ok funcionando perfeito) so que td que eu crio aqui da esse pau se alguém puder me ajudar serei grato, pois so falta isso para terminar o sisteminha pra ela. Error: Internal error. Developer Details: tNG_fields.getFakeRecordset: SQL error: Error creating temporary table: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'desc TEXT, id TEXT)' at line 1 SQL: CREATE TEMPORARY TABLE KT_fakeRS_20120904 (mini TEXT, imagem TEXT, desc TEXT, id TEXT) (FIELDS_FAKE_RS_ERROR) tNG Execution Trace - VIEW •tNG_insert.executeTransaction ◦STARTER.Trigger_Default_Starter •tNG_insert.getRecordset •tNG_insert.getLocalRecordset •tNG_insert.getFakeRecordset* obs: já testei banco esta ok * tb já desisntalei o wamp e instalei novamente * atualizei a pasta include tb * deletei os arquivos que eu fiz e tentei refaze-los e o erro permanece * já pesquisei na net sobre isso e não encontrei praticamente nada então espero que alguém me ajude . Obrigado