1
My web application should access two different databases on different servers, put the column of the two databases on the screen and compare the result between them.
However, it only returns the value of one of the banks and the other it returns everything zero as the image.
while ($line = mysql_fetch_array($table_primal1) && $lineup = mysql_fetch_array($table_primal2) ) {
$convert2 = (float) $line['campo016'];
$convertup = (float) $lineup['campo016'];
if($convertup==$convert2){
$compara = 'Correto';
$printtr = 'trcorrect';
$printtd = 'correct';
} else {
$compara = 'Erro';
$printtr = 'trerror';
$printtd = 'error';
}
echo'<tr class='.$printtr.'>';
echo'<td class='.$printtd.'>' .$line['papel']. '</td>';
echo'<td class='.$printtd.'>' .$line['campo036']. '</td>';
echo'<td class='.$printtd.'>' .$convert2. '</td>';
echo'<td class='.$printtd.'>' .$convertup. '</td>';
echo'<td class='.$printtd.'>' .$compara. '</td>';
echo'</tr>';
The code that should do this is basically that. I tried to put a while inside the other, but it just returns me the first result of the other column and dps repeats.
Follow my Querys:
$table_primal1 = mysql_query("SELECT * FROM quotes where origem='30' and papel like 'ZS_8' AND campo012 >= '0' AND campo016 >='0' or origem='30' and papel like 'ZC_8' AND campo012 >= '0' AND campo016 >='0' or origem='30' and papel like 'ZL_8' AND campo012 >= '0' AND campo016 >='0' or origem='30' and papel like 'ZS_7' AND campo012 >= '0' AND campo016 >='0' or origem='30' and papel like 'ZC_7' AND campo012 >= '0' AND campo016 >='0' or origem='30' and papel like 'ZL_7' AND campo012 >= '0' AND campo016 >='0' or origem='30' and papel like 'ZS_9' AND campo012 >= '0' AND campo016 >='0' or origem='30' and papel like 'ZC_9' AND campo012 >= '0' AND campo016 >='0' or origem='30' and papel like 'ZL_9' AND campo012 >= '0' AND campo016 >='0' ORDER BY papel ASC",$conexao_ori30a);
$table_primal2 = mysql_query("SELECT * FROM quotes where origem='30' and papel like 'ZS_8' AND campo012 >= '0' AND campo016 >='0' or origem='30' and papel like 'ZC_8' AND campo012 >= '0' AND campo016 >='0' or origem='30' and papel like 'ZL_8' AND campo012 >= '0' AND campo016 >='0' or origem='30' and papel like 'ZS_7' AND campo012 >= '0' AND campo016 >='0' or origem='30' and papel like 'ZC_7' AND campo012 >= '0' AND campo016 >='0' or origem='30' and papel like 'ZL_7' AND campo012 >= '0' AND campo016 >='0' or origem='30' and papel like 'ZS_9' AND campo012 >= '0' AND campo016 >='0' or origem='30' and papel like 'ZC_9' AND campo012 >= '0' AND campo016 >='0' or origem='30' and papel like 'ZL_9' AND campo012 >= '0' AND campo016 >='0' ORDER BY papel ASC", $conexao_ori30b);
Cade
mysql_query()
?– rray
The
querys()
seem right, also puts themysql_connect()
:P– rray
I updated with them
– Geraldão de Rívia
This connection I can not show, but I can guarantee that it is working perfectly, because I had managed to print the two tables perfectly while they were separate
– Geraldão de Rívia
Okay, when you call the
mysql_connect()
informs 4 arguments? the last beingtrue
? example:mysql_connect('localhost', 'usuario', 'senha', true);
– rray
No, I call $login = mysql_connect('localhost', 'user', 'password') and dps call mysql_select_db('bank', $login)
– Geraldão de Rívia
Raisin
true
on both calls frommysql_connect()
, should solve the problem. I imagine that the server, user and password are the same.– rray
As I said in the question, the tables are on separate servers. ?
– Geraldão de Rívia
Even passing the
true
didn’t work?– rray
I keep the mysql_select_database right?
– Geraldão de Rívia
Yes, let
mysql_select_database
normal.– rray
That was the first example I gave :(
– Geraldão de Rívia