Ver Mensaje Individual
  #5 (permalink)  
Antiguo 10/01/2009, 08:59
spacewars
(Desactivado)
 
Fecha de Ingreso: agosto-2008
Mensajes: 30
Antigüedad: 15 años, 9 meses
Puntos: 0
Respuesta: Error warning fopen()

Rehola de nuevo señores, poco tiempo ha pasado hasta darme cuanta de que necesito vuestra ayuda, he estado leyendo algunas webs y al final en wiki encontré la manera de hacer el "fsockopen" he modificado el code pero ahora me da el error:

Código PHP:
Fatal errorOnly variables can be passed by reference in 
Me podéis echar una mano?, os dejo el código adjunto.

Código PHP:
<?#//v.3.0.0

#///////////////////////////////////////////////////////
#//  COPYRIGHT 2008 ALL RIGHTS RESERVED//
#///////////////////////////////////////////////////////

Function ConvertCurrency($FROM,$INTO,$AMOUNT)
{
    
$query "SELECT * FROM bay_rates WHERE symbol='$FROM'";
    
$R         mysql_query($query);
    if(!
$R)
    {
        print 
"Error: $query<BR>".mysql_error();
        exit;
    }
    
$F_RATE    mysql_fetch_array($R);

    
$query "SELECT * FROM bay_rates WHERE symbol='$INTO'";
    
$R_     mysql_query($query);
    if(!
$R_)
    {
        print 
"Error: $query<BR>".mysql_error();
        exit;
    }
    
$I_RATE    mysql_fetch_array($R_);

    
$VAL     doubleval($AMOUNT);
    return 
$VAL/$F_RATE[rate]*$I_RATE[rate];
}


function 
UpdateRates()
{
 global 
$PHP_SELF;
 
$interval 1440// Minutes in 1 day

 
$res = @mysql_query("select *,NOW()-(last_update) as dif from bay_lastupdate;");
 
$ar = @mysql_fetch_array($res);
 
$mydif = (int)($ar[dif]/60) - $interval;
 if(
$mydif>0)
 
 
/*{
  $fp = fopen("http://www.bankofcanada.ca/fmd/exchange.htm","r");
  $x=0;$g=0;
  while(!feof($fp))
  {
*/
    
$fp fsockopen(“www.bankofcanada.ca/fmd/exchange.htm”8030);
        if( !
$fp ) {
        echo 
'$errstr ($errno) <br>\n';
} else {
    
fputs($fp“GET HTTP/1.0nn”);
        while( !
feof($fp) ) {
        echo 
fgets($fp128);
    }
    
fclose($fp);
}


   
$buf fgets($fp4096);
   if(
eregi("U.S. Dollar",$buf)) $x=4;
   if(
eregi("</PRE>",$buf)) $x=0;
   if(
$x==4)
   {
    if(!
eregi("US/CA",$buf))
    {
     
$ime explode("/",$buf);
     
$s explode(" ",$ime[1]);
     
$r array_reverse ($s);

     if(
eregi("Euro de",$buf))
     {
      
$ime[0]="European Monetary Union EURO";
      
$s explode(" ",$buf);
      
$r array_reverse ($s);
     }

     if(
$ime[0]<>"" and $r[0]<>"")
     {
      
$g++;
      if(
eregi("U.S. Dollar",$buf)) {$koef = (float)$r[0];}
      
$k = ((float)$r[0]/(float)$koef);
      
$usd 1/$k;
      
$res mysql_query("SELECT * FROM bay_rates WHERE sifra=\"$ime[0]\"") or die("ERROR 42:".mysql_error());
      
$num mysql_num_rows($res);
      if(
$num == 0)
      {
         
mysql_query("INSERT INTO bay_rates VALUES(
                     NULL,
                     \"$ime[0]\",
                    '',
                    $usd,
                    \"$ime[0]\")"
);
      }
      else
         
mysql_query("UPDATE bay_rates SET rate='$usd' WHERE sifra=\"$ime[0]\"");
     }
    if(
eregi("Venezuelan Bolivar",$buf)) $x=0;
    }
   }
  }
  
fclose($fp);
  
mysql_query("UPDATE bay_lastupdate SET last_update=NOW();");
 }
}
?>
Espero vuestra ayuda. Gracias a todos.