don11 Posted February 22, 2011 Share Posted February 22, 2011 Hello, I need help. I want to know how to copy a field value of a table from one database to other database using php. I have a field name "invites" in a table "members" in database "db1" and a field name "new_invites" in a table "new_members" in database "db2". I want to copy value of field "invites" to "new_invites". How to do that? Quote Link to comment Share on other sites More sharing options...
don11 Posted February 22, 2011 Author Share Posted February 22, 2011 I was trying and i have a problem. Please take a look at this code: //doing a query from db1: $query = "SELECT invitation FROM contact"; $which = $link1; mysql_query($query,$which); $result="$kk"; How to store the result in $kk? Quote Link to comment Share on other sites More sharing options...
Muddy_Funster Posted February 22, 2011 Share Posted February 22, 2011 you hav't assigned anything to $result $result = mysql_query($query,$which) or die ('Error performing database lookup -- '.mysql_error()); Now that gets you a value attached to $result, However, this isn't your actual data from your database. Next you need to call the data into an array, and as you next to never have a single row of data in a table, you will need to run through each row by using a while loop. Once you have the information into the array, you can then pull it out into a flat variable such as $kk. Look up some examples online on how to use mysql_fetch_assoc(), or better still get a book on php and mysql from amazon or somewhere, it will make a much more convenient refference. Quote Link to comment Share on other sites More sharing options...
don11 Posted February 22, 2011 Author Share Posted February 22, 2011 Thanks alot Muddy_Funster, now i got it. Thanks alot. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.