jay123 Posted July 31, 2014 Share Posted July 31, 2014 Im trying to compare two different server table and compare match email output. please tell me whats wrong in my code. <?php $master = mysql_pconnect("master_host","10.0.3.37","recover"); $slave = mysql_pconnect("slave_host","10.0.3.24","popular"); 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 "; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/290215-new-on-phpmysql/ Share on other sites More sharing options...
requinix Posted August 1, 2014 Share Posted August 1, 2014 (edited) $slave_sql = mysql_query("SELECT * FROM popular_screamer_archive1 WHERE email = " . $row['email'],$slave);That won't create valid SQL because strings need quotes. Add quotes and use mysql_real_escape_string() on the email address. And I don't think array_combine() is what you want to use. Not really sure what you're trying to do with it in the first place. And don't use persistent connections unless you know all about their problems and don't mind suffering for it. And please stop using the mysql extension and its mysql_* functions. It's old, slow, and deprecated. Switch to PDO or mysqli. Edited August 1, 2014 by requinix Quote Link to comment https://forums.phpfreaks.com/topic/290215-new-on-phpmysql/#findComment-1486585 Share on other sites More sharing options...
LeJack Posted August 1, 2014 Share Posted August 1, 2014 Also, please note that appending the i after mysql will not work. You have to legit know how the MySQLi library works. As of now, 000webhost is supporting PHP 5.4 which means they're probably going to remove the older MySQL library. Quote Link to comment https://forums.phpfreaks.com/topic/290215-new-on-phpmysql/#findComment-1486591 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.