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
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
Share on other sites

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.

Link to comment
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.