xilllly Posted November 22, 2011 Share Posted November 22, 2011 Hi, I'm trying to copy some values from a table called "member" to a table called "report" when new members submit a php application form. I can't see what's wrong with it. I have attached screenshots of the 2 tables and their structure. Any help would be much appreciated. global $conn,$dal; $customerID = mysql_insert_id(); $strSQLInsert = "insert into report (appID, memberID, select_agent, agent_details, first_name, last_name, street_address, suburb, postcode) values (".$ID.", ".$ID.", '".$values["select_agent"]."', '".$values["agent_details"]."', '".$values["first_name"]."', '".$values["last_name"]."', '".$values["street_address"]."', '".$values["suburb"]."', '".$values["postcode"]."')"; db_exec($strSQLInsert,$conn); [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/251592-whats-wrong-with-this-insert-code/ Share on other sites More sharing options...
trq Posted November 22, 2011 Share Posted November 22, 2011 What does your query actually look like when you echo it? What errors are you getting? Quote Link to comment https://forums.phpfreaks.com/topic/251592-whats-wrong-with-this-insert-code/#findComment-1290360 Share on other sites More sharing options...
xilllly Posted November 22, 2011 Author Share Posted November 22, 2011 I'm not actually getting any errors, it just doesn't copy the values from "member" table to "report" table as I'd like it too. It used to work fine but now it doesn't for some reason. Maybe I a ' instead of a " somewhere I suspect. Xilllly Quote Link to comment https://forums.phpfreaks.com/topic/251592-whats-wrong-with-this-insert-code/#findComment-1290594 Share on other sites More sharing options...
jcbones Posted November 22, 2011 Share Posted November 22, 2011 MySQL is a relational database. So you shouldn't be copy`in anything to another table. Just send over the unique id for the row you want to "copy". If the same data resides in multiple tables in your application, you will run into bottle necks in the future. Just a helpful note. Quote Link to comment https://forums.phpfreaks.com/topic/251592-whats-wrong-with-this-insert-code/#findComment-1290596 Share on other sites More sharing options...
xilllly Posted November 22, 2011 Author Share Posted November 22, 2011 Thanks. Can you give some example code for that? Xilllly Quote Link to comment https://forums.phpfreaks.com/topic/251592-whats-wrong-with-this-insert-code/#findComment-1290602 Share on other sites More sharing options...
jcbones Posted November 24, 2011 Share Posted November 24, 2011 Go here, and read about "ignoring normalization" the whole article is great, but that is the part to pay particular attention to. Then make sure to watch all 9 lessions. Then familiarize yourself with MySQL's JOIN syntax. Perhaps then you may wish for a lesson in using it, or you could ask for some help here. Quote Link to comment https://forums.phpfreaks.com/topic/251592-whats-wrong-with-this-insert-code/#findComment-1290873 Share on other sites More sharing options...
xilllly Posted November 24, 2011 Author Share Posted November 24, 2011 Thanks jcbones. Will look at those. Xilllly Quote Link to comment https://forums.phpfreaks.com/topic/251592-whats-wrong-with-this-insert-code/#findComment-1290874 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.