Ver Mensaje Individual
  #2 (permalink)  
Antiguo 19/12/2011, 05:16
Avatar de Eleazan
Eleazan
 
Fecha de Ingreso: abril-2008
Ubicación: Ibiza
Mensajes: 1.879
Antigüedad: 16 años, 1 mes
Puntos: 326
Respuesta: consulta y update

Mira, si usas la herramienta highlight del foro, queda mucho más legible (y es más fácil ayudarte!)

Código PHP:
<?php
$dbhost 
'localhost';
$dbuser 'local';
$dbpass 'local';

$conn mysql_connect($dbhost$dbuser$dbpass) or die('Error connecting to mysql');
$dbname 'pruebas';
mysql_select_db($dbname);
$query "select reference from product_attribute";

$result mysql_query($query);

while (
$row mysql_fetch_array($result)) {
    
//if ($row['reference']!="")
    //{
    
    
$conection mssql_connect("localhost""local""local") or die("no se puede conectar a SQL Server");
    
//aqui selecciono la base Northwind que ya trae MS SQL v.8 como ejemplo
    
mssql_select_db("Northwind"$conection);
    
//tu consulta la asignas a un string $SQL
    
    
$SQL "SELECT UnitsInStock FROM Products where ProductID='" $row['reference'] . "'";
    
    echo (
$row['reference']);
    
$result mssql_query($SQL$conection);
    while (
$row2 mssql_fetch_array($result)) {
        
$conn2 mysql_connect($dbhost$dbuser$dbpass) or die('Error pincha mysql');
        
$dbname 'pruebas';
        
mysql_select_db($dbname$conn2);
        
$query2 "update ps_product_attribute set quantity='" $row2['UnitsInStock'] . "' where reference='" $row['reference'] . "'";
        echo (
"update");
        
mysql_query($query2$conn2);
    }
    
mssql_close($conection);
}

mysql_close($conn);


?>
PD: Prueba a cambiar tu segundo $result a otro nombre ;)
__________________
>> Eleazan's Source
>> @Eleazan