Hi guys,
Am new at PHP so please bear with me if this is a stupid question but can PHP run a pass through query.
If so please can someone help me with this. I have a query with calculates the last number of an autonumber field within a table. I can change the type of query to a passthrough query and then would like to call this number and use it in my PHP form by adding 1to this number and this will give me the next id number I need to be assigned to the submitted form
Please help if this can be done and sorry for wasting your time if it can't.
Cheers
PHP and pass through queries
Moderator: General Moderators
Re: PHP and pass through queries
No, don't do that.
If you're inserting new data into a table you shouldn't care about the ID until after the insert happened. You can look it up easily and reliably at that point.
If you're inserting new data into a table you shouldn't care about the ID until after the insert happened. You can look it up easily and reliably at that point.
Re: PHP and pass through queries
Yup, assigning the id before the the data is submitted could cause all sorts of problems - for example, if you have 3 people connect to the page at the same time, all three will be given the next id which means they would update the table and replace each others data. You need mysql_insert_id() once you've run your insert query
Re: PHP and pass through queries
Thanks for the replies and sorry for the delay in replying.
Used the mysql_insert_id() and this worked a treat.
Cheers
Used the mysql_insert_id() and this worked a treat.
Cheers