Ver Mensaje Individual
  #5 (permalink)  
Antiguo 17/02/2012, 11:02
danielmeza
 
Fecha de Ingreso: febrero-2012
Mensajes: 24
Antigüedad: 13 años
Puntos: 0
Respuesta: Mysql php y SSH

Uff Por fin avances,

ya tengo mi codigo algo avanzado.

Código PHP:
<?php
//header("Content-Type: application/vnd.ms-excel");
//header("Expires: 0");
//header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
//header("content-disposition: attachment;filename=Reportes.xls");
?>
<HTML LANG="es">
<TITLE>::. Exportacion de Datos .::</TITLE>
</head>
<body>
//<?php
// $NombreBD = "Prueba";
// $Servidor = "192.168.1.4";
//$Usuario = "test";
//$Password ="123456";

$User '*****48'
    
$Pass '********'
    
$remotehost 'traficobk.globalpc.net'
    
$host '127.0.0.1';
    
$Servidor '127.0.0.1';
    
$connection ssh2_connect($remotehost'2201');     
     if (
ssh2_auth_password($connection$User,$Pass)) 
         {  
            echo 
"Conexion exitosa\n"
            print
"<br><br>";
            if (
$tunnel ssh2_tunnel($connection$host,'3306'))             
            { 
             echo 
"Tunnel OK";
              print
"<br><br>";
            } 
            else  
                { 
                    echo 
"Fallo el Tunel.";
                } 
        } 
        else  
        {  
            die(
'Authenticacion Fallida...');  
        } 
   
  echo 
"Proceso terminado";  
  print
"<br><br>";

$IdConexion mysql_connect($Servidor$User$Pass) or die ("Error al Conectar!");
mysql_select_db($NombreBD$IdConexion) or die ("Error con Base de Datos! Cinco");

$sql "SELECT sNumPedimento, sCveTrafico, eTipoReferencia, ePedimentoConsolidado, iCveEmbarque, IConsecutivoOficina FROM cb_trafico Where sNumPedimento='$_POST[pedimento]' AND sCveAduana='$_POST[aduana]'";
$result=mysql_query($sql,$IdConexion);
?>

<TABLE BORDER=1 align="center" CELLPADDING=1 CELLSPACING=1>

<?php
while($row mysql_fetch_assoc($result)) {
//while($row = mysql_fetch_array($result)) {
printf("<TR>
<td>"
.$row["C001PATEN"]."</td>
<td>"
.$row["C001ADUSEC"]."</td>
<td>"
.$row["C001REFPED"]."</td>
<td>"
.$row["C001NUMPED"]."</td>
<td>"
.$row["C001TIPOPE"]."</td>
<td>"
.$row["D001FECEXT"]."</td>
<td>"
.$row["D001FECREM"]."</td>
<td>"
.$row["C001ADUSE"]."</td>
<td>"
.$row["D001FECCAM"]."</td>
<td>"
.$row["F001VALSEG"]."</td>
"
);
}
mysql_free_result($result);
mysql_close($IdConexion); //Cierras la Conexión
?>
</table>
</body>
</html>
ok, empezando el código, hace el ssh2_connect y arroja //Conexion exitosa

luego ssh2_tunnel y me da Túnel OK

pero luego sigue Mysql_connect, y palos, Error al Conectar!,

me estoy intentando conectar a 127.0.0.1 por 3306 que es lo que me trajo de vuelta el túnel, intente también intentar hacer el túnel por mi ip lan 192.168.1.4 y entonces me da Túnel Fallo, si uso otra ip que no sea localhost me falla el túnel, y si intento usar otro puerto que no sea 3306 me falla el túnel,

Alguna Idea?


Gracias!

Última edición por danielmeza; 17/02/2012 a las 11:50