Advertisement
Guest User

traduction

a guest
Dec 7th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.29 KB | None | 0 0
  1. <?php
  2.  
  3. if (isset($_GET["noma"]) and isset($_GET["prenoma"]))
  4. {
  5.     $n = $_GET["noma"] ;
  6.     $p = $_GET["prenoma"];
  7.     $res = array();
  8.    
  9.     $n = iconv('UTF-8', 'UTF-16LE', $n); //convert into native encoding
  10.     $n = bin2hex($n);
  11.  
  12.     $p = iconv('UTF-8', 'UTF-16LE', $p); //convert into native encoding
  13.     $p = bin2hex($p);
  14.  
  15.     $serverName = "41.231.120.155";
  16.     $uid = "SQLCW";
  17.     $pwd = "AWaWDa9L**";
  18.     $dbname = "Reference_Traduction";
  19.  
  20.     $connectionInfo = array( "Database"=>"$dbname", "UID"=>"$uid", "PWD"=>"$pwd");
  21.     $conn = sqlsrv_connect( $serverName, $connectionInfo);
  22.  
  23.     $sqln = "select NOMF from NOM
  24.     where NOMA=CONVERT(nvarchar(MAX), 0x$n)";
  25.  
  26.     $sqlp = "select PRENOMF from Feuil1Prenom
  27.     where PRENOMA=CONVERT(nvarchar(MAX), 0x$p)";
  28.    
  29.     $stmtn = sqlsrv_query( $conn, $sqln);
  30.     $stmtp = sqlsrv_query( $conn, $sqlp);
  31.  
  32.     $res["nom"] = array();
  33.     $res["prenom"] = array();
  34.  
  35.     while( $row = sqlsrv_fetch_array( $stmtn, SQLSRV_FETCH_ASSOC) ) {
  36.         $res["nom"][] = $row['NOMF'] ;
  37.     }
  38.  
  39.     while( $row = sqlsrv_fetch_array( $stmtp, SQLSRV_FETCH_ASSOC) ) {
  40.         $res["prenom"][] = $row['PRENOMF'] ;
  41.     }
  42.  
  43.     header('Content-type: application/json');
  44.     echo json_encode($res,JSON_PRETTY_PRINT);
  45. /*
  46.     if( $stmt === false ) {
  47.          die( print_r( sqlsrv_errors(), true));}
  48.          */
  49.     sqlsrv_close( $conn);
  50. }
  51.  
  52.  
  53. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement