2012-11-25, 04:27 PM
Hello,
I want to define a task that reads some elements from mybb db and writes them in an external db, i have written a php code like this for doing the task :
I will give a little explanation about code, it first gets all users of mybb by uid,email,timeonline then connects to external db searches for each email, if email is available in external DB it will set timeonline value of that user with value reads from mybb DB then closes external DB and sets those users timeonline to 0 in mybb DB.
Now the above just simply doesn't work can anyone help me to find out what i'm doing wrong ?!
I want to define a task that reads some elements from mybb db and writes them in an external db, i have written a php code like this for doing the task :
<?php
$query = $db->simple_select("users", "uid,email,timeonline");
while ($info = $db->fetch_array($query))
$this->connection = mysql_connect("External DB IP", "User", "Pass");
mysql_select_db("DB Name", $this->connection);
$email = $info['email'];
$q = "SELECT timeonline FROM table_name WHERE email = '$email'";
$result = mysql_query($q, $this->connection);
if(!$result || (mysql_numrows($result) < 1)){
}
else {
$value = $info['timeonline'];
$q = "UPDATE table_name SET timeonline = '$value' WHERE email = '$email'";
mysql_query($q, $this->connection);
}
mysql_close($this->connection);
$value = 0;
$db->update_query("users", array('timeonline' => '$value'), 'uid=$info[\'uid\']';
?>
I will give a little explanation about code, it first gets all users of mybb by uid,email,timeonline then connects to external db searches for each email, if email is available in external DB it will set timeonline value of that user with value reads from mybb DB then closes external DB and sets those users timeonline to 0 in mybb DB.
Now the above just simply doesn't work can anyone help me to find out what i'm doing wrong ?!