Jump to content

Recommended Posts

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 ";

}

?>

Link to comment
https://forums.phpfreaks.com/topic/290215-new-on-phpmysql/
Share on other sites

$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 by requinix
Link to comment
https://forums.phpfreaks.com/topic/290215-new-on-phpmysql/#findComment-1486585
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.