note 44141 rejected from function.mssql-bind by tularis

From: Date: Thu, 15 Jul 2004 22:55:27 +0000
Subject: note 44141 rejected from function.mssql-bind by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-73341@lists.php.net to get a copy of this message
Note Submitter: sistemas@hackermail.com ---- a single example, jeje, trivial this is my procedure in sql server://este es mi p.a en mi base de datos. CREATE PROCEDURE Ver_cliente @Id nvarchar(30) output -- IMPORTANTE!!! AS select [clientes].cCedula as Cedula, [clientes].cNombres as Nombres, [clientes].cApellidos as Apellidos, [clientes].cDireccion as Direccion, [clientes].desResidencia as "Ciudad Residencia", --[clientes].cCiudadResidencia as "Codigo Ciudad", [clientes].cTelefono as Telefono, [clientes].cPase as Pase, [clientes].siCategoria as Categoria, [clientes].sdVencimiento as Vencimiento, [clientes].cMovil as Movil, [clientes].promedioCalificacion as Calificacion, oficinas.cCiudad as Oficina, [clientes].iCodigoFotografico as CodigoFotografico, [clientes].bActivo as Activo, --bAprobado as Aprobado, [clientes].bRevisado as Revisado, [clientes].deuda as Debe_$, [clientes].CreadoPor as CreadoPor, (usuarios.cNombres + ' ' + usuarios.cApellidos) as "NombreCreadoPor" from [clientes] inner join oficinas on [clientes].ioficina = oficinas.iCodigo inner join usuarios on usuarios.ccedula = clientes.CreadoPor where [clientes].cCedula = @Id GO ********************************************** this my code in php , taked from others examples ;-) <?php $file_type = "vnd.ms-excel"; $file_ending = "xls"; //} header("Content-Type: application/$file_type"); header("Content-Disposition: attachment; filename=file_name.$file_ending"); header("Pragma: no-cache"); header("Expires: 0"); //get contents //puede ser la fecha actual $now_date = date('d-m-Y H:i'); $title = "Listado Personas $now_date"; $sql = "Select * from clientes"; $valor = 8400038; //id from client /* Database Connection (Alternative- for mysql_fetch_array) */ $conex = mssql_connect("yourserver","sa","123"); mssql_select_db("yourdatabase"); $proc = mssql_init("Ver_Cliente", $conex) or die("Hay problemas para conectar a Stored Procedure"); mssql_bind($proc, "@Id", &$valor, SQLVARCHAR, true) or die("Hay problemas para crear bind");/*parametro &$valor pasado por referencia. true = is_output, like the declaration in the procedure code above */ $result=mssql_execute($proc) or die ("Error sacando el procedimiento almacenado"); //end of connection code //define separator (defines columns in excel) $sep = "\t"; //print excel header with timestamp: echo("$title\n"); //start of printing column names for ($i = 0; $i < mssql_num_fields($result); $i++) { echo mssql_field_name($result,$i) . "\t"; } print("\n"); //end of printing column names //start while loop to get data /* note: the following while-loop was taken from phpMyAdmin 2.1.0. --from the file "lib.inc.php". */ $i = 0; while($row = mssql_fetch_row($result)) { //set_time_limit(60); // HaRa $schema_insert = ""; for($j=0; $j<mssql_num_fields($result);$j++) { if(!isset($row[$j])) $schema_insert .= "NULL".$sep; elseif ($row[$j] != "") $schema_insert .= "$row[$j]".$sep; else $schema_insert .= "".$sep; } $schema_insert = str_replace($sep."$", "", $schema_insert); $schema_insert .= "\t"; print(trim($schema_insert)); print "\n"; $i++; } return (true); ?> it's all folks, ***************************** Cesar Correa from Bello, Medellin, Colombia

« previous php.notes (#73341) next »