Foros del Web » Programando para Internet » PHP »

Algien Puede Decir Que Tiene Mal

Estas en el tema de Algien Puede Decir Que Tiene Mal en el foro de PHP en Foros del Web. ESTE ES EL CODIGO: Cita: if (isset($_POST['vende']) && isset($_POST['fechain'])&& isset($_POST['fechaf'])) { $FI = $_POST['fechain']; $FF = $_POST['fechaf']; $ven = $_POST['vende']; $producto = "1"; $consulta= "SELECT ...
  #1 (permalink)  
Antiguo 26/11/2007, 17:40
Avatar de viqtor  
Fecha de Ingreso: noviembre-2007
Ubicación: Donde estoy?
Mensajes: 49
Antigüedad: 16 años, 5 meses
Puntos: 0
Exclamación Algien Puede Decir Que Tiene Mal

ESTE ES EL CODIGO:

Cita:
if (isset($_POST['vende']) && isset($_POST['fechain'])&& isset($_POST['fechaf'])) {


$FI = $_POST['fechain'];
$FF = $_POST['fechaf'];
$ven = $_POST['vende'];
$producto = "1";

$consulta= "SELECT C.cod_cte, C.razon_social, isnull((select top 1 fecha from entysal where status <> 'C' and fecha between '@FI' and '@FF' and cod_cte = C.cod_cte and vendedor = '@vendedor' and cod_prod = '@producto' and transaccion in ('36','37','38') order by fecha desc),'') as ultima_venta, isnull((select top 1 fecha from mpedcte where status <> 'C' and fecha between '@FI' and '@FF' and cod_cte = C.cod_cte and vendedor = '@vendedor' and cod_prod = '@producto' and transaccion = '31' order by fecha desc),'') as ultima_pedido, isnull((select sum(cantidad) from entysal where folio in (select top 1 folio from entysal where status <> 'C' and fecha between '@FI' and '@FF' and cod_cte = C.cod_cte and vendedor = '@vendedor' and cod_prod = '@producto' and transaccion in ('36','37','38') order by fecha desc)),0.0) as cantidad_venta, isnull((select sum(cantidad_pedida) from mpedcte where folio in (select top 1 folio from mpedcte where status <> 'C' and fecha between '@FI' and '@FF' and cod_cte = C.cod_cte and vendedor = '@vendedor' and cod_prod = '@producto' and transaccion = '31' order by fecha desc)),0.0) as cantidad_pedido, isnull((select status from pedcte where folio in (select top 1 folio from mpedcte where status <> 'C' and fecha between '@FI' and '@FF' and cod_cte = C.cod_cte and vendedor = '@vendedor' and cod_prod = '@producto' and transaccion = '31' order by fecha desc)),'') as status_pedido FROM CLIENTES C where vendedor = '@vendedor'" ;

$consulta = str_replace('@FI',$FI,$consulta);
$consulta = str_replace('@FF',$FF,$consulta);
$consulta = str_replace('@vendedor',$ven,$consulta);
$consulta = str_replace('@producto',$producto,$consulta);
}
?>

Cita:
<?php

$result = mssql_query($consulta);
while( $row = mssql_fetch_array( $result ) ){
//cierra mas abajo ?>
Y ME MANDA EL SIGUIENTE ERROR

Warning: mssql_query() [function.mssql-query]: Query failed in C:\AppServ\www\areacomercial.starfruts.com.mx\vend edor01.php on line 124

Warning: mssql_fetch_array(): supplied argument is not a valid MS SQL-result resource in C:\AppServ\www\areacomercial.starfruts.com.mx\vend edor01.php on line 125
  #2 (permalink)  
Antiguo 26/11/2007, 17:43
Avatar de mauled  
Fecha de Ingreso: marzo-2005
Ubicación: Cd. de México.
Mensajes: 3.001
Antigüedad: 19 años, 1 mes
Puntos: 33
Re: Algien Puede Decir Que Tiene Mal: Urge

Te sugiero que modifiques esta linea
Código PHP:
$result mssql_query($consulta); 
por

Código PHP:
$result mssql_query($consulta)or or exit(mssql_get_last_message()); 
Y veas que error esta teniendo tu query.

Saludillos
  #3 (permalink)  
Antiguo 26/11/2007, 17:53
Avatar de viqtor  
Fecha de Ingreso: noviembre-2007
Ubicación: Donde estoy?
Mensajes: 49
Antigüedad: 16 años, 5 meses
Puntos: 0
Re: Algien Puede Decir Que Tiene Mal: Urge

YA hice el cambio que me sugeriste y me regresa este error:

Warning: mssql_query() [function.mssql-query]: Query failed in C:\AppServ\www\areacomercial.starfruts.com.mx\vend edor01.php on line 124
Changed database context to 'BMS_2004'.

Cita:
$link = mssql_connect ($host, $user, $password) or die ("<center>No se puede conectar con la base de datos\n</center>\n");
mssql_select_db(BMS_2004) or die("Imposible seleccionar la base de datos. Porfavor, intentelo mas tarde");
Ese es el nombre correcto de mi base
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 00:41.