Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
galera eu estava fazendo esse curso de criacao de loja virtual e ai td bem...mas chegando em uma aula que o professor cria a insercao de categorias esta sempre ocorrendo um erro que na video aula nao consta,ja fiz um monte de vez e mesmo assim nao sai do erro e nao exibi corretamente a pagina.
conexao.php
<?php
$servidor = "localhost";
$usuario = "root";
$senha = "";
$con = mysql_connect($servidor, $usuario, $senha) or die("não foi possivel conectar");
mysql_select_db("loja", $con) or die("não foi possivel conectar ao banco de dados");
?>
cabecalho.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">](http://www.w3.org/1999/xhtml)
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">.style1 {
font-size: 12px;
font-weight: bold;
}</style>
</head>
<body>
<table width="779" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="2%"> </td>
<td width="35%"><img src="imagens/logo.jpg" width="210" height="117" /></td>
<td width="60%"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td width="58%"> </td>
<td width="42%"><img src="imagens/tit.jpg" width="186" height="38" /></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td colspan="2"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="24%"><span class="style1">login:</span></td>
<td width="72%"><span class="style2"><strong>Data</strong>:
<?php
$dia_da_semana = array("Domingo" , "Segunda" , "Terça" , "Quarta" , "Quinta" , "Sexta" , "Sábado");
$num_dia = date('w');
$dia_extenso = $dia_da_semana[$num_dia];
echo $dia_extenso." ,".date("d/m/Y");?>
-<strong> Hora: </strong><?php echo date("H:i");?>
- <strong>IP
</strong>: <?php echo getenv("REMOTE_ADDR");?>
</span></td>
<td width="4%"> </td>
</tr>
</table></td>
</tr>
<tr>
<td colspan="2"></td>
</tr>
</table></td>
<td width="3%"> </td>
</tr>
</table></td>
</tr>
<tr>
<td><img src="imagens/menu1.gif" width="758" height="27" /></td>
</tr>
</table>
</body>
</html>
menu.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">](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="200" height="100" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="31"> </td>
<td width="138"> </td>
<td width="31"> </td>
</tr>
<tr>
<td> </td>
<td><table width="178" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="imagens/admin_menu.gif" width="178" height="31" /></td>
</tr>
<tr>
<td><table width="100%" height="100" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="8%"> </td>
<td width="93%" valign="top">
<a href="categoria.php">Categorias</a>
<a href="subcategoria.php">SubCategorias</a>
<a href="produtos.php">Produtos</a>
<a href="clientes.php">Clientes</a>
</td>
</tr>
</table></td>
</tr>
</table></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
</body>
</html>
rodape.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">](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><div align="center"><img src="imagens/img_inf.gif" width="758" height="20" /></div></td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</body>
</html>
index.php
<?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">](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="750" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2"><?php include "cabecalho.php"; ?></td>
</tr>
<tr>
<td width="161"><?php include "menu.php"; ?></td>
<td width="589"> </td>
</tr>
<tr>
<td colspan="2"><?php include "rodape.php"; ?></td>
</tr>
</table>
</body>
</html>
categoria.php
<?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">](http://www.w3.org/1999/xhtml)
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">.style1 {
font-size: 12px;
font-weight: bold;
}</style>
</head>
<body>
<table width="750" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2"><?php include "cabecalho.php"; ?></td>
</tr>
<tr>
<td width="161"><?php include "menu.php"; ?></td>
<td width="589"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><div align="center" class="style1">Categoria</div></td>
</tr>
<tr>
<td><div align="center">
<?php
if ($acao != ""){
$sql = mysql_query("SELECT * FROM categorias WHERE id = $id"); ?>
<form id="form1" name="form1" method="post" action="<?php echo $PHP_SELF;?>">
<table width="300" border="1" cellspacing="0" cellpadding="2">
<tr>
<td width="20%"><span class="style1">Categoria</span></td>
<td width="80%"><input name="txtcategoria" type="text" id="txtcategoria" size="35" /></td>
</tr>
<tr>
<td colspan="2">
<div align="center">
<input type="submit" name="Submit" value="Inserir" />
</div></td>
</tr>
</table>
</form>
<?php }else{ ?>
<table width="99%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td width="88%"><strong><span class="style2">Categorias</span></strong></td>
<td colspan="2"><div align="center"><strong>Ação</strong></div></td>
</tr>
<?php $sql = mysql_query("SELECT * FROM categorias");
while($coluna = mysql_fetch_array($sql)){?>
<tr>
<td><?php $coluna['categoria'];?></td>
<td width="6%"><img src="imagens/alterar.png" width="16" height="16" /></td>
<td width="6%"><img src="imagens/excluir.png" width="16" height="16" /></td>
</tr>
<?php } ?>
<tr>
<td colspan="3"><div align="right"><img src="imagens/inserir.png" width="16" height="16" /></div></td>
</tr>
</table>
<?php } ?>
<p> </p>
</div></td>
</tr>
</table></td>
</tr>
<tr>
<td colspan="2"><?php include "rodape.php"; ?></td>
</tr>
</table>
</body>
</html>
loja.sql
-- phpMyAdmin SQL Dump
-- version 3.2.0.1
-- http://www.phpmyadmin.net
--
-- Servidor: localhost
-- Tempo de Geração: Fev 08, 2010 as 07:43 PM
-- Versão do Servidor: 5.1.36
-- Versão do PHP: 5.3.0
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
--
-- Banco de Dados: loja
--
-- --------------------------------------------------------
--
-- Estrutura da tabela administracao
--
CREATE TABLE IF NOT EXISTS `administracao` (
`id_admin` int(11) NOT NULL AUTO_INCREMENT,
`nome` varchar(120) NOT NULL,
`email` varchar(200) NOT NULL,
`login` varchar(30) NOT NULL,
`senha` varchar(20) NOT NULL,
PRIMARY KEY (`id_admin`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
--
-- Extraindo dados da tabela administracao
--
-- --------------------------------------------------------
--
-- Estrutura da tabela categorias
--
CREATE TABLE IF NOT EXISTS `categorias` (
`id_categoria` int(11) NOT NULL AUTO_INCREMENT,
`categoria` varchar(100) NOT NULL,
PRIMARY KEY (`id_categoria`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
--
-- Extraindo dados da tabela categorias
--
INSERT INTO categorias (id_categoria, categoria) VALUES
(1, 'video aulas'),
(2, 'cursos');
-- --------------------------------------------------------
--
-- Estrutura da tabela clientes
--
CREATE TABLE IF NOT EXISTS `clientes` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`cliente` varchar(100) NOT NULL,
`email` varchar(200) NOT NULL,
`senha` varchar(20) NOT NULL,
`endereco` varchar(100) NOT NULL,
`bairro` varchar(100) NOT NULL,
`cidade` varchar(100) NOT NULL,
`estado` char(2) NOT NULL,
`cep` varchar(9) NOT NULL,
`telefone` varchar(20) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
--
-- Extraindo dados da tabela clientes
--
-- --------------------------------------------------------
--
-- Estrutura da tabela produtos
--
CREATE TABLE IF NOT EXISTS `produtos` (
`id_produto` int(11) NOT NULL AUTO_INCREMENT,
`id_categoria` int(11) NOT NULL,
`id_subcategoria` int(11) NOT NULL,
`produto` varchar(100) NOT NULL,
`foto` varchar(150) NOT NULL,
`descricao` text NOT NULL,
`estoque` int(11) NOT NULL,
`preco` double NOT NULL,
`lancamento` int(11) NOT NULL,
PRIMARY KEY (`id_produto`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
--
-- Extraindo dados da tabela produtos
--
-- --------------------------------------------------------
--
-- Estrutura da tabela subcategorias
--
CREATE TABLE IF NOT EXISTS `subcategorias` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id_categoria` int(11) NOT NULL,
`subcategoria` varchar(50) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
--
-- Extraindo dados da tabela subcategorias
--
O meu problema se encontra em categoria.php.
alguem poderia me ajudar soh sei que o cara la nao iniciou a variavel acao mas mesmo assim na video aula deu certinho...nao entendi porque...ME AJUDEM.VLW
Carregando comentários...