Re: Multiple Inserts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Solved....... I needed to find a way to get the latest auto_increment value.
I did this using,

$new_id = mysql_insert_id();

Thanks,
Declan.

----------------------------
Thanks for the suggestions. I have
$TimeSheetID=$_POST['TimeSheetID'];
at the start of the script. However, what I neglected to mention is that
TimeSheetID is auto_increment, in first table, tblTimesheet.

I will try the other suggestions, and respond with my results.

Thanks,
Declan.


-----------------------------------------------
Good point.  Since it's form data, what about $_POST['TimesheetID'] ?

> Don't see anything obviously wrong with your query string. Are the inserts
> happening in the same block of code, i.e., are you sure that
> _$TimesheetID_ has a value in it when you're performing the second insert?
>
>
> -dave
>
>
>> I am using a form to Insert data into 2 tables in the same database.
>
>> $TimesheetID needs to be in each table. However, it is not being
> inserted
>> into the second table, "tblTimesheetDetails" . Any advise?
>
>> $result_timesheet=mysql_query("INSERT INTO tblTimesheet (TimesheetID,
>> WorkerID, ClientID, TimesheetDate, ProspectiveOrRetrospective) VALUES
>>
>
('$TimeSheetID','$WorkerID','$ClientID','$TimesheetDate','$ProspectiveOrRetr
>> ospective')")or die("Insert Error: ".mysql_error());
>
>> $result_timesheetdetails=mysql_query("INSERT INTO tblTimesheetDetails
>> (TimesheetID, ActivityTypeID, TimeSpentHours, TimeSpentMinutes) VALUES
>>
>
('$TimeSheetID','$ActivityTypeID','$TimeSpentHours','$TimeSpentMinutes')")or
>> die("Insert Error: ".mysql_error());
>

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux