Erro ao inserir dados na fatura para conclusao

Enviada por alan 
alan
Erro ao inserir dados na fatura para conclusao
04 de January de 2001 às 06:06PM
Estou desenvolvendo uma aplicacao ,e-commerce e ao inserir os dados que seguem desde do login ate a insercao do produto na fatura me aparece o seguinte erro Warning: 0 is not a MySQL result index in /home/lutex/lutex-www/fatura.php3 on line 33


o mesmo aparece para a linha 52 , ja verifiquei e parece estar tudo correto. e abaixo vai o codigo completo para vc que analisar me dar uma solucao.....




<?
require("config.ini");
?>

<head>
<title><? echo $sigla; ?></title>
</head>
<body bgcolor="<? echo $bgForm ?>">

<?
$db = mysql_connect("localhost", "lutex", "amY7AtgA") or die("Erro de Conexão");
mysql_select_db("lutex_com_br", $db) or die("Base de dados não existe");

$sql = "Select priNome, numNota from clientela "
."where emaCliente = '$emaCliente'";
$resSql = mysql_query($sql, $db);
$priNome = mysql_result($resSql,$counter,"priNome");
$numNota = mysql_result($resSql,$counter,"numNota");

if ($numNota == 999999999) {
$sql = "Select min(numNota) as Numero FROM clientela";
$resSql = mysql_query($sql, $db);
$numNota = mysql_result($resSql,$counter,"Numero") - 1;
$sql = "Update clientela set numNota = $numNota "
."where emaCliente = '$emaCliente'";
$resSql = mysql_query($sql, $db);
}

$sql = "Select nidItem FROM Movimento where numNota = $numNota";
$resSql = mysql_query($sql, $db);
$numItem = mysql_numrows($resSql) + 1;

$sql = "Insert Into Movimento (numNota, nidItem, nidProduto, "
."prcUnitario, qtdVendida) Values ($numNota, $numItem, "
."'$nidProduto', $prcUnitario, $qtdVendida)";
$resSql = mysql_query($sql, $db);

?>

<h1><img src="<? echo $dirImage; ?>carrinho.gif" border="0">Fatura</h1>

<table width=100%>
<tr bgColor=<? echo $corTab; ?> ><th>Item</th><th>Produto</th><th width=90>Quantidade</th>
<th width=90>Valor Unit</th><th width=90>Valor Total</th></tr>

<?
$sql = "Select * from Movimento where numNota = $numNota order by nidItem";
$resSql = mysql_query($sql, $db);
$totGeral = 0;
while ($valor = mysql_fetch_array($resSql)) {
$total = $valor["prcUnitario"] * $valor["qtdVendida"];
$totGeral = $totGeral + $total;

$nidProduto = $valor["nidProduto"];
$sql = "Select nomProduto from lista where nidProduto = '$nidProduto'";
$res2 = mysql_query($sql, $db);

echo "<tr>";
echo "<td>".$valor["nidItem"]."</td>";
echo "<td>".mysql_result($res2,$counter,"nomProduto")."</td>";
echo "<td align=right>".$valor["qtdVendida"]."</td>";
echo "<td align=right>".$valor["prcUnitario"]."</td>";
echo "<td align=right>$total</td></tr>";
}
?>
</table>

<br>
<p class=titulo>
Usuario: <? echo $priNome; ?><br>
Data da Compra: <? echo date('d/m/Y'); ?><br>
Valor Total: <? echo $totGeral; ?></p>

<?
if ($fechar == "") {
?>

<table>
<tr><td>
<form action="<? echo $PHP_SELF."?fechar='S'"; ?>" method="POST">
<input type=HIDDEN name=emaCliente value="<? echo $emaCliente ?>">
<input type=submit value="Finalizar">
</form>
</td><td>
<form action="escolha.php3" method="POST">
<input type=HIDDEN name=emaCliente value="<? echo $emaCliente ?>">
<input type=submit value="Continuar">
</form>
</td></tr>
</table>

<?
} else {

$sql = "Insert Into nota (datCompra, emaCliente, prcTotVenda)"
." Values (now(), '$emaCliente', $totGeral)";
$resSql = mysql_query($sql, $db);

$sql = "Select max(numNota) as Numero from nota where emaCliente = '$emaCliente'";
$resSql = mysql_query($sql, $db);
$numero = mysql_result($resSql,$counter,"Numero");

$sql = "Update movimento set NumNota = $numero "
." where NumNota = $numNota";
$resSql = mysql_query($sql, $db);

$sql = "Update Clientela set numNota = 999999999 "
."where emaCliente = '$emaCliente'";
$resSql = mysql_query($sql, $db);

?>
<form action="menu_raiz.php3" method="POST">
<input type=HIDDEN name=emaCliente value="<? echo $emaCliente ?>">
<p class="titulo">Pedido Concluído sem problemas</p>
<input type=submit value="Retornar">
</form>

<?
}
?>
</body>
Você precisa estar logado no PHPBrasil.com para poder enviar mensagens para os nossos fóruns.

Faça o login aqui.