PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
JACK233
Forum Newbie
Posts: 4 Joined: Fri Aug 01, 2014 9:36 am
Post
by JACK233 » Fri Aug 01, 2014 9:38 am
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 ";
}
?>
Last edited by
Celauran on Fri Aug 01, 2014 10:54 am, edited 1 time in total.
Reason: Please wrap your code in syntax tags for legibility.
Celauran
Moderator
Posts: 6427 Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada
Post
by Celauran » Fri Aug 01, 2014 10:55 am
JACK233 wrote: please tell me whats wrong in my code.
Please tell us what errors you're encountering.
JACK233
Forum Newbie
Posts: 4 Joined: Fri Aug 01, 2014 9:36 am
Post
by JACK233 » Fri Aug 01, 2014 11:22 am
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.
Celauran
Moderator
Posts: 6427 Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada
Post
by Celauran » Fri Aug 01, 2014 11:33 am
Code: Select all
if(mysql_select_db("recover",$master) && mysql_select_db("popular",$slave))
So that's failing. Have you checked mysql_error() ?
JACK233
Forum Newbie
Posts: 4 Joined: Fri Aug 01, 2014 9:36 am
Post
by JACK233 » Fri Aug 01, 2014 11:36 am
how can i check that? cuz im really new on php/mysql. this is my first time using this both language.
Celauran
Moderator
Posts: 6427 Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada
Post
by Celauran » Fri Aug 01, 2014 12:05 pm
Code: Select all
if(mysql_select_db("recover",$master) && mysql_select_db("popular",$slave)) {
// stuff
} else {
echo mysql_error();
}
JACK233
Forum Newbie
Posts: 4 Joined: Fri Aug 01, 2014 9:36 am
Post
by JACK233 » Fri Aug 01, 2014 12:19 pm
its not giving me error anymore but its not showing me anything either, screen is blank.