Page 1 of 1

need help with php/mysql, anyone?

Posted: Fri Aug 01, 2014 9:38 am
by JACK233
I'm trying to compare two different server tables and compare the match email output. please tell me whats wrong in my code.

Code: Select all

<?php

$master = mysql_connect("master_host","10.0.3.37","gramercy");
$slave = mysql_connect("slave_host","10.0.3.24","gramercy");

if(mysql_select_db("recover",$master) && mysql_select_db("popular",$slave))
{
//Both Selected
$sql = mysql_query("SELECT * FROM recover_unsub1",$master);
$rows = array();
while($row = mysql_fetch_assoc($sql))
{

$slave_sql = mysql_query("SELECT * FROM popular_screamer_archive1 WHERE email = " . $row['email'],$slave);
while($sub_row = mysql_fetch_assoc($slave_sql))
{
$row = array_combine($sub_row,$row);
}
$rows[] = $row;
}
}
else {
print "Database NOT Found ";
}
?>

Re: need help with php/mysql, anyone?

Posted: Fri Aug 01, 2014 10:55 am
by Celauran
JACK233 wrote:please tell me whats wrong in my code.
Please tell us what errors you're encountering.

Re: need help with php/mysql, anyone?

Posted: Fri Aug 01, 2014 11:22 am
by JACK233
my code giving me Error# Database Not Found


im trying to connect two server and trying to get match email output. Both tables are in differnt server and both tablet has email column.

Re: need help with php/mysql, anyone?

Posted: Fri Aug 01, 2014 11:33 am
by Celauran

Code: Select all

if(mysql_select_db("recover",$master) && mysql_select_db("popular",$slave))
So that's failing. Have you checked mysql_error() ?

Re: need help with php/mysql, anyone?

Posted: Fri Aug 01, 2014 11:36 am
by JACK233
how can i check that? cuz im really new on php/mysql. this is my first time using this both language.

Re: need help with php/mysql, anyone?

Posted: Fri Aug 01, 2014 12:05 pm
by Celauran

Code: Select all

if(mysql_select_db("recover",$master) && mysql_select_db("popular",$slave)) {
    // stuff
} else {
    echo mysql_error();
}

Re: need help with php/mysql, anyone?

Posted: Fri Aug 01, 2014 12:19 pm
by JACK233
its not giving me error anymore but its not showing me anything either, screen is blank.