need help with php/mysql, anyone?

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

Post Reply
JACK233
Forum Newbie
Posts: 4
Joined: Fri Aug 01, 2014 9:36 am

need help with php/mysql, anyone?

Post 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 ";
}
?>
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.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: need help with php/mysql, anyone?

Post by Celauran »

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

Re: need help with php/mysql, anyone?

Post 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.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: need help with php/mysql, anyone?

Post 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() ?
JACK233
Forum Newbie
Posts: 4
Joined: Fri Aug 01, 2014 9:36 am

Re: need help with php/mysql, anyone?

Post by JACK233 »

how can i check that? cuz im really new on php/mysql. this is my first time using this both language.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: need help with php/mysql, anyone?

Post by Celauran »

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

Re: need help with php/mysql, anyone?

Post by JACK233 »

its not giving me error anymore but its not showing me anything either, screen is blank.
Post Reply