Forum Moderators: coopster

Message Too Old, No Replies

Php MySql problems

         

may_hem1

4:39 pm on Jun 6, 2004 (gmt 0)

10+ Year Member



Hi there,

I wonder if anyone can help? In my online shop which is created using php and MySql db, I have created a page where the client has to submit contact details to our MySql db, another page which lets the user review the submitted details and a third page from where the user can change the submitted contact details. Now, my problem is that:

1. The user details in the review page and in the change details page contain information from the last entered row in the database. That can cause problem in case there are 2 or more users submitting their contact details at nearly the same time, as the last entered row in the db is not going to match their entry. I think using session object would solve the problem here, but I have no idea how to do it.

2. The second problem that concerns me is that at the moment my page adds a new row to the db every time the data is submitted. I want to stop that and add a new row to the db only if the same item within that particular order with the same quantity doesn't exist already.

Can anyone help please?

Thanks

May

lorax

6:09 pm on Jun 6, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



... can cause problem in case there are 2 or more users submitting their contact details at nearly the same time, as the last entered row in the db is not going to match their entry...

On the same page that their record is created use mysql_insert_id [php.net] to get the id of the record and set this as a session var. This should eliminate the issue of two user submitting at the same time as both the initial insert and the retrieval of the ID occur within the same page.

You might find this useful for the second issue as well.