By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,984 Members | 2,686 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,984 IT Pros & Developers. It's quick & easy.

INSERTING data into MySQL using PHP Scripting

Odisey
P: 14
OK -I can do this in PhpMyAdmin (hard coded) - so its not a DB problem.

I am just getting started - thank you for the help.

I am creating a page to INSERT user information into two tables.

The first table is easy to accomplish. The user first and last name, e address, and they set a password - is INSERTED. VALUES pass and the user_id PRIMARY increments automatically - a record is stored.

The second table is a credit card table. It is a tinyblob which is necessary. I am using a @salt also. The record sets, no problem. I SELECT the @salt, and then AES_ENCRYPT the input value using the salt to the table. As said no problem.

Here is where I am not getting the logic. When I set the user table values, the PRIMARY key auto increments - right. I have created a column in the encode table (where the credit card info is stored) named user_id to act as the FOREIGN key INDEX. So that I can reference the credit card value through identifying the user's user_id in the users table. I do not know how to set the user_id in the FOREIGN key column in the second table to correlate, as it auto_increments in the first table. I have no idea how to send that same number to the second table.

Thank you,
Marc
May 20 '07 #1
Share this Question
Share on Google+
2 Replies


Odisey
P: 14
NO edit button...?

I guess I need to use the $mysql_insert_id function following the initial insert...don't know the syntx though. Any ideas?

Marc
May 20 '07 #2

pbmods
Expert 5K+
P: 5,821
NO edit button...?
YES edit button... but only for 5 minutes after you post ;)

You'll be wanting to take a look at mysql_insert_id. Invoke mysql_insert_id after the target query, but before any other queries have a chance to execute.
May 20 '07 #3

Post your reply

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