Skip to main content
Known Participant
January 10, 2011
Question

PHP MySQL SELECT INSERT

  • January 10, 2011
  • 1 reply
  • 1907 views

I have a registration page with a html form. I have created an insert record server behavior that insert all the data into a MySQL database table fine. What I like to do additionally is to insert the data from a single row, actually the last row, into another table in the same mysql database. I have heard of MySQL insert-select but I can't seem to make it work on my own.  Is insert-select possible with Dreamweaver? If not, what should I use?

I appreciate any help

This topic has been closed for replies.

1 reply

January 10, 2011

Inserting all data into another table is redundant. You only need to pass the primary key to a new table when necessary and use the JOIN argument in your query to JOIN data from seperate tables for one user.

irajiAuthor
Known Participant
January 10, 2011

Sorry if I was misleading. I like to pass the data from 3 columns of the last row of the table to another table.

Participating Frequently
January 10, 2011

The order of your insert fields is not the same as your select fields which is probably why it is failing.

Also, I don't really see a need for be_notified table. Can't those fields just be added to the user table? Also, why is the table called new_user? Is there a regular 'user' table?

What happens when 2 users register at the same time?  User1 inserts into the new_user table and before the be_notified script fires, another users registers. Now the first be_notified scripts inserts the wrong data.

Also, why inser the confirm_password and confirm_email data? There should never be a reason that those fields are different - it needs to be validated before your insert.


Ah, yes as TS found, you are redirecting before the sql gets executed. But it will still not work after you fix that because of the field order issue.