Ver Mensaje Individual
  #1 (permalink)  
Antiguo 10/10/2012, 13:42
karma274
 
Fecha de Ingreso: septiembre-2012
Ubicación: Norte de Santander
Mensajes: 127
Antigüedad: 14 años, 2 meses
Puntos: 1
Exclamación conexion a dos bases de datos.....

Hola,
tengo un problemita lo que pasa es que necesito actualizar datos de una tabla de una base de datos desde otra tabla en otra base de datos, asi que mi consulta es la siguiente: Ya tengo las dos conexiones pero no las puedo colocar en el mismo script me manda un error que dice tabla sii_11.actaf no existe. Aqui les dejo el codigo para que entiendan un poco mas.
Codigo:
Código PHP:
<?php
ini_set
('max_execution_time', 300);
//Exportar datos de php a Excel
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=Reporteactualizados.xls");
include(
"../../conexiones/conexion.php");

$rt = mysql_query("SELECT * FROM actaf");
$ntotal = mysql_num_rows($rt);
$rs = mysql_query("SELECT * FROM actaf WHERE nmatricula = 0");
    while(
$registro = mysql_fetch_assoc($rs)){
include(
"../../conexiones/conexionSii.php");
        
$rf = mysql_query("SELECT * FROM mreg_est_matriculados WHERE numid=".$registro['cedula']." and estmatricula = 'MA' and fecmatricula >= '20120801'");
        while(
$fila = mysql_fetch_assoc($rf)){
            if(
$fila['organizacion'] != 02){
                
$q="UPDATE actaf SET 
                    nmatricula = '"
.$fila['matricula']."', 
                    fecha = '"
.$fila['fecmatricula']."' 
                    WHERE cedula = '"
.$fila['numid']."'
                    "
;
                    
mysql_query($q,$link) or die (mysql_error());
            }
        }
    }
$regact = mysql_affected_rows($link);
$rs = mysql_query("SELECT * FROM actaf WHERE nmatricula = 0");
$nregcero = mysql_num_rows($rs);
$nregmat= $ntotal-$nregcero;
?>
<html>
<head>
<title></title>
</head>
<table border="1">
<tr><td colspan="2"><b>REPORTE DE ACTUALIZACION DE MATRICULAS</b></tr>
<tr><td><b>REGISTROS TOTALES EN ACTA DE FORMALIZACION</b></td><td><?php echo $ntotal; ?></td></tr>
<tr><td><b>REGISTROS CON MATRICULAS</b></td><td><?php echo $nregmat; ?></td></tr>
<tr><td><b>REGISTROS CON MATRICULAS EN CERO</b></td><td><?php echo $nregcero; ?></td></tr>
<tr><td><b>MATRICULAS ACTUALIZADAS</b></td><td><?php echo $regact; ?> </td></tr>
</table>
</html>

Última edición por karma274; 10/10/2012 a las 13:52