Jump to content

New on PHP/MYSQL


jay123

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.

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.