473,398 Members | 2,113 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

mysql-php error message

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $todb            = 'localhost';
  3. $fromdb          = 'test1.deftlogic.com';
  4. $smstable        = sms;
  5. $paid_bribetable = bd_paidabribe;
  6. $countertable    = tab3;
  7.  
  8. //connecting to the local database
  9. $con = mysql_pconnect($todb, 'dtestfor_ipab', 'IaMzieU3#b%$'); //servername,username,password
  10. if (!$con) {
  11.     die("couldn't connect");
  12. }
  13.  
  14. mysql_select_db("dtestfor_IPAB_db", $con); //databasename
  15.  
  16. $rs2 = mysql_query("select sms_index as 'ma' from " . $countertable . "", $con);
  17.  
  18. $max = mysql_fetch_assoc($rs2);
  19.  
  20. print_r($max['ma']);
  21. //connecting to the local database ends
  22. //connecting to the remote database
  23. $dblink2 = mysql_pconnect($fromdb, 'dtestone_ipab', '!*D-pD)g5)FJ'); // connect server 2
  24.  
  25. mysql_select_db('dtestone_db_2025', $dblink2); // select database 2
  26.  
  27. //echo $dblink2;
  28.  
  29. if (!$dblink2) {
  30.     echo "not connected";
  31. } else
  32.     echo "db2 connected";
  33.  
  34. $rs    = mysql_query("select Message from " . $smstable . " where sms_index >" . $max['ma'], $dblink2);
  35. $msgs  = mysql_fetch_assoc($rs);
  36. $msgs2 = array();
  37. //connecting to the remot database ends
  38. //connecting to the local database
  39. do {
  40.     array_push($msgs2, $msgs['Message']);
  41. } while ($msgs = mysql_fetch_assoc($rs));
  42.  
  43. $con = mysql_pconnect($todb, 'dtestfor_ipab', 'IaMzieU3#b%$'); //servername,username,password
  44. if (!$con) {
  45.     die("couldn't connect");
  46. }
  47.  
  48. mysql_select_db("dtestfor_IPAB_db", $con); //databasename
  49.  
  50. foreach ($msgs2 as $m) {
  51.     $m2 = explode(",", $m);
  52.     mysql_query("insert into " . $paid_bribetable . "(city,dept,amount) values('" . $m2[0] . "','" . $m2[1] . "','" . $m2[2] . "')", $con);
  53. }
  54. //connecting to the local database ends
  55. //connecting to the remot database  
  56. $dblink2 = mysql_pconnect($fromdb, 'dtestone_ipab', '!*D-pD)g5)FJ'); // connect server 2
  57.  
  58. mysql_select_db('dtestone_db_2025', $dblink2); // select database 2
  59.  
  60. $rs4  = mysql_query("select max(sms_index) as 'ma' from " . $smstable . "");
  61. $max2 = mysql_fetch_assoc($rs4);
  62. //connecting to the remot database ends
  63. //connecting to the local database
  64. $con  = mysql_pconnect($todb, 'dtestfor_ipab', 'IaMzieU3#b%$'); //servername,username,password
  65. if (!$con) {
  66.     die("couldn't connect");
  67. }
  68.  
  69. mysql_select_db("dtestfor_IPAB_db", $con);
  70.  
  71. mysql_query("UPDATE '" . $countertable . "' SET sms_index = " . $max2['ma']);
  72. //connecting to the local database ends
  73. ?>

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...
Apr 25 '12 #1
4 1550
johny10151981
1,059 1GB
everything is right with syntax but some thing is wrong with your Query that you didnt write.

here is it
Expand|Select|Wrap|Line Numbers
  1. $Query="...";
  2. $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. 
  3. //now if you try this
  4. $row=mysql_fetch_assoc($res); // you will get error.
  5.  
  6.  
  7.  
Apr 25 '12 #2
Dormilich
8,658 Expert Mod 8TB
I’d hazard a guess at 'ma' (invalid context for a string)
Apr 25 '12 #3
@dormilich 'ma' is just used as a temporary value to store the details collected from the table...
Apr 25 '12 #4
Dormilich
8,658 Expert Mod 8TB
check the SQL error message then. I wouldn’t be the least bit surprised if that’s the position where the error is occuring.
Apr 25 '12 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
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 ? ...
0
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, ...
0
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...
2
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:...
1
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...
0
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...
74
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...
39
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...
1
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....
2
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
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...
0
Oralloy
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,...
0
jinu1996
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...
0
agi2029
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,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.