Ir para conteúdo
Fórum Script Brasil
  • 0

problemas com Recordset


ferspaik

Pergunta

pessoal, estou com um problema no meu script, mas não consigo achar o erro, quando rodo ele com um echo no RsInsertPedido me retorna isso:

INSERT INTO adm_n_pedidos (np_sessao, np_cliente, np_status, np_cod_envio, np_detalhes, np_data_pedido) VALUES ('', '', '0', 'NULL', 'NULL', '2009/05/30')

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\wamp\www\alexandre3\finalizar.php on line 52

o que é super estranho uma vez q na tabela, np_sessao e np_cliente, são campos NOT NULL, e no BD ele grava sem nada ficando assim:

np_id np_sessao np_cliente np_status np_cod_envio np_detalhes np_data_pedido

9 0 0 NULL NULL 2009/05/30

qual é o problema com meu script q ele não insere nem a sessao e nem o id do cliente?

por favor é urgente!

muito obrigado!

<?php require_once('Connections/alexandre.php'); ?>
<?php
session_start();
$sessao = session_id();
if($sessao == "".session_id()."") {
session_regenerate_id();
}
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}
//******************************//
mysql_select_db($database_alexandre, $alexandre);
$query_RsVerificaPedido = "SELECT np_id FROM adm_n_pedidos WHERE np_sessao = '$sessao'";
$RsVerificaPedido = mysql_query($query_RsVerificaPedido, $alexandre) or die(mysql_error());
$row_RsVerificaPedido = mysql_fetch_assoc($RsVerificaPedido);
$totalRows_RsVerificaPedido = mysql_num_rows($RsVerificaPedido);
//**************//
$npid = $row_RsVerificaPedido['np_id'];
$usuid = $_SESSION['kt_login_id'];
$data = date('Y/m/d');
//******************************************//
if($npid == "") {
//******************************************//
mysql_select_db($database_alexandre, $alexandre);
$query_RsInsertPedido = "INSERT INTO adm_n_pedidos (np_sessao, np_cliente, np_status, np_cod_envio, np_detalhes, np_data_pedido) VALUES ('$sessao', '$usuid', '0', 'NULL', 'NULL', '$data')";
$RsInsertPedido = mysql_query($query_RsInsertPedido, $alexandre) or die(mysql_error());
$row_RsInsertPedido = mysql_fetch_assoc($RsInsertPedido);
//*****************************************//
}
//*********************************//
mysql_select_db($database_alexandre, $alexandre);
$query_RsListaPedido = "SELECT np_id FROM adm_n_pedidos WHERE np_sessao = '$sessao'";
$RsListaPedido = mysql_query($query_RsListaPedido, $alexandre) or die(mysql_error());
$row_RsListaPedido = mysql_fetch_assoc($RsListaPedido);
$totalRows_RsListaPedido = mysql_num_rows($RsListaPedido);
//*****************************//
mysql_select_db($database_alexandre, $alexandre);
$query_RsSomaTotal = "SELECT sum(ipd_preco *ipd_quantidade) as somatotal FROM adm_itens_pedido_ipd WHERE ipd_sessao = '$sessao'";
$RsSomaTotal = mysql_query($query_RsSomaTotal, $alexandre) or die(mysql_error());
$row_RsSomaTotal = mysql_fetch_assoc($RsSomaTotal);
$totalRows_RsSomaTotal = mysql_num_rows($RsSomaTotal);
?><!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>BRASILbet - Pedido Finalizado</title>
<style type="text/css">
<!--
.style1 {
    color: #FFFFFF;
    font-weight: bold;
}
-->
</style>
</head>

<body>
<div id="status" style="padding-top:10px; padding-bottom:10px; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:16px; color:#333333"> &raquo; <span class="style3">Meus Pedidos</span> <span class="style3">&raquo; Entrega <strong>&raquo; Finalizado </strong></span></div>
<table width="100%">
  <tr>
    <td height="30" bgcolor="#000000"><div align="center" class="style1">Pedido Finalizado - N&uacute;mero: <?php echo $row_RsListaPedido['np_id']; ?></div></td>
  </tr>
  <tr>
    <td><p>O seu pedido foi realizado com sucesso.</p>
      <p>Valor Total do pedido: </p>
      <p>Lembrando que somente ser&aacute; cobrado o valor dos cart&otilde;es que forem solicitados a ativa&ccedil;&atilde;o do mesmo. <br />
        </p></td>
  </tr>
</table>
</body>
</html>
<?php
mysql_free_result($RsSomaTotal);

mysql_free_result($RsListaPedido);

mysql_free_result($RsVerificaPedido);
?>

Editado por ferspaik
Link para o comentário
Compartilhar em outros sites

0 respostass a esta questão

Posts Recomendados

Até agora não há respostas para essa pergunta

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152k
    • Posts
      651,8k
×
×
  • Criar Novo...