- <?php
-
$todb = 'localhost';
-
$fromdb = 'test1.deftlogic.com';
-
$smstable = sms;
-
$paid_bribetable = bd_paidabribe;
-
$countertable = tab3;
-
-
//connecting to the local database
-
$con = mysql_pconnect($todb, 'dtestfor_ipab', 'IaMzieU3#b%$'); //servername,username,password
-
if (!$con) {
-
die("couldn't connect");
-
}
-
-
mysql_select_db("dtestfor_IPAB_db", $con); //databasename
-
-
$rs2 = mysql_query("select sms_index as 'ma' from " . $countertable . "", $con);
-
-
$max = mysql_fetch_assoc($rs2);
-
-
print_r($max['ma']);
-
//connecting to the local database ends
-
//connecting to the remote database
-
$dblink2 = mysql_pconnect($fromdb, 'dtestone_ipab', '!*D-pD)g5)FJ'); // connect server 2
-
-
mysql_select_db('dtestone_db_2025', $dblink2); // select database 2
-
-
//echo $dblink2;
-
-
if (!$dblink2) {
-
echo "not connected";
-
} else
-
echo "db2 connected";
-
-
$rs = mysql_query("select Message from " . $smstable . " where sms_index >" . $max['ma'], $dblink2);
-
$msgs = mysql_fetch_assoc($rs);
-
$msgs2 = array();
-
//connecting to the remot database ends
-
//connecting to the local database
-
do {
-
array_push($msgs2, $msgs['Message']);
-
} while ($msgs = mysql_fetch_assoc($rs));
-
-
$con = mysql_pconnect($todb, 'dtestfor_ipab', 'IaMzieU3#b%$'); //servername,username,password
-
if (!$con) {
-
die("couldn't connect");
-
}
-
-
mysql_select_db("dtestfor_IPAB_db", $con); //databasename
-
-
foreach ($msgs2 as $m) {
-
$m2 = explode(",", $m);
-
mysql_query("insert into " . $paid_bribetable . "(city,dept,amount) values('" . $m2[0] . "','" . $m2[1] . "','" . $m2[2] . "')", $con);
-
}
-
//connecting to the local database ends
-
//connecting to the remot database
-
$dblink2 = mysql_pconnect($fromdb, 'dtestone_ipab', '!*D-pD)g5)FJ'); // connect server 2
-
-
mysql_select_db('dtestone_db_2025', $dblink2); // select database 2
-
-
$rs4 = mysql_query("select max(sms_index) as 'ma' from " . $smstable . "");
-
$max2 = mysql_fetch_assoc($rs4);
-
//connecting to the remot database ends
-
//connecting to the local database
-
$con = mysql_pconnect($todb, 'dtestfor_ipab', 'IaMzieU3#b%$'); //servername,username,password
-
if (!$con) {
-
die("couldn't connect");
-
}
-
-
mysql_select_db("dtestfor_IPAB_db", $con);
-
-
mysql_query("UPDATE '" . $countertable . "' SET sms_index = " . $max2['ma']);
-
//connecting to the local database ends
-
?>
Hi all.....i am trying to get the values from sms table which is on one server and insert those values into another table in another server. while doing that i'm using another table that will check the max value in sms table accordingly it will insert the values. all the code seems fine but when i execute the code i'm getting the error message as Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource on (url) in line no 37,45,67. i think the wrong is there with the syntax. any help will be much appreciated.....thanks in advance...
4 1550
everything is right with syntax but some thing is wrong with your Query that you didnt write.
here is it -
$Query="...";
-
$res=mysql_query($Query);//here is Query is incorrect or query is not suppose to return any resource such as update query, insert query or delete query.
-
//now if you try this
-
$row=mysql_fetch_assoc($res); // you will get error.
-
-
-
I’d hazard a guess at 'ma' (invalid context for a string)
@dormilich 'ma' is just used as a temporary value to store the details collected from the table...
check the SQL error message then. I wouldn’t be the least bit surprised if that’s the position where the error is occuring.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: user mysql |
last post by:
HELLO FRIENDS. HERE A FANTASTIC NEWS FOR MYSQL WINDOWS USER. READE
THIS.
The article is grab from www/internetnews/com/
DO YOU THINK THAT IS A GOOD NEWS ?
...
|
by: Miguel Perez |
last post by:
Hi Guys:
Does anyone know how come I'm getting a lot of mysql processes when I start
mysql server for the first time.
When I type top it showed the following:
5:33pm up 15 min, 4 users, ...
|
by: Yun Guan |
last post by:
Hello mysql gurus,
I am trying to run perl on mysql database on Red Hat box. I want to install
DBI and DBD:mysql using CPAN:
perl -MCPAN -e shell
cpan>install DBI
The above succeeded, but...
|
by: Saqib Ali |
last post by:
I installed mySQL and have it running.... but I think I made a
mistake somewhere along the line...... I believe I did follow the
instructions that were provided with the distribution at:...
|
by: Alex Hunsley |
last post by:
I am trying to install the DBD::mysql perl module. However, it claims I
need mysql.h:
cpan> install DBD::mysql
CPAN: Storable loaded ok
Going to read /home/alex/.cpan/Metadata
Database was...
|
by: ./Rob & |
last post by:
Hi gang:
I'm experiencing a problem with MySQL -- I updated MySQL from version 4.1.0
to 4.1.10 and now when I login as root it doesn't show all the databases I
should have access to, nor it...
|
by: John Wells |
last post by:
Yes, I know you've seen the above subject before, so please be gentle with
the flamethrowers.
I'm preparing to enter a discussion with management at my company
regarding going forward as either...
|
by: Mairhtin O'Feannag |
last post by:
Hello,
I have a client (customer) who asked the question : "Why would I buy and
use UDB, when MySql is free?"
I had to say I was stunned. I have no experience with MySql, so I was
left sort...
|
by: Good Man |
last post by:
Hi there
I've noticed some very weird things happening with my current MySQL setup
on my XP Laptop, a development machine.
For a while, I have been trying to get the MySQL cache to work....
|
by: trihanhcie |
last post by:
I m currently working on a Unix server with a fedora 3 as an os
My current version of mysql is 3.23.58. I'd like to upgrade the version
to 5.0.18.
After downloading from MYSQL.COM the package on...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |