Ver Mensaje Individual
  #1 (permalink)  
Antiguo 28/07/2009, 09:29
delfin85
 
Fecha de Ingreso: julio-2008
Mensajes: 59
Antigüedad: 15 años, 9 meses
Puntos: 1
Exclamación tengo un error y no c de q es

Warning: mssql_query(): supplied argument is not a valid MS SQL-Link resource in C:\wamp\www\Datos2\insertar.php on line 58
No se pude conectar


Código PHP:
<?php require_once('conexion.php'); 

function 
GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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;
}

$editFormAction $_SERVER['PHP_SELF'];
//if (isset($_SERVER['QUERY_STRING'])) {
//  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
//}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  
$insertSQL sprintf("INSERT INTO datos (nombre, colonia, fecha, ciudad, folio) VALUES (%s, %s, %s, %s, %s)",
                       
GetSQLValueString($_POST['nombre'], "text"),
                       
GetSQLValueString($_POST['colonia'], "text"),
                       
GetSQLValueString($_POST['fecha'], "date"),
                       
GetSQLValueString($_POST['ciudad'], "text"),
           
GetSQLValueString(Consecutivo('reportel'), "text"));

  
$Result1 mssql_query($insertSQL$cnnConexion) or die("No se pude insertar");
}

function 
Consecutivo($lcFormulario){
    require_once(
'conexion.php');
    
$data="Select * FROM consecutivo WHERE formulario='".$lcFormulario."'";
    
$Result mssql_query($data$cnnConexion) or die("No se pude conectar a consecutivo");
    
$numRow mssql_num_rows($Result);
    
$rowcon mssql_fetch_array($Result);
    
    
$lcConsecutivo=str_pad(trim($rowcon["numero"])+15'0'STR_PAD_LEFT);
        
    
$lcPrefijo=trim($rowcon["prefijo"]);
    
    
$lcRetorno=$lcPrefijo."-".$lcConsecutivo."/".date("y");
    
    
$lcNumero=trim($rowcon["numero"])+1;
    
$queryData="Update consecutivo SET numero=".$lcNumero." WHERE formulario='".$lcFormulario."'";
    
    
$result mssql_query($queryData$cnnConexion) or die("No se pude insertar");
    
    return 
$lcRetorno;    
}


?>



lo q ago es q genero un numero de folio y me marca error al accesar la tabla concecutivo

lo raro es q si la conecion se la pongo toda completa en la pagina si lo hace

lo q no entiendo es por q si solo mando llamar la conexion no lo hace
Código PHP:
$myServer "SISTEMAS";
$myUser "us";
$myPass "php";
$myDB "prueba"

//conecxion a la base de datos
$cnnConexion mssql_pconnect($myServer$myUser$myPass)
  or die(
"No se pudo conectar al servidor"); 
//select a database to work with
$selected mssql_select_db($myDB$cnnConexion)
  or die(
"No se pude abrir la base de datos"); 

Última edición por delfin85; 28/07/2009 a las 11:51