i am working on a project where i have to insert records in two diffetent table at a time so i am using transactions but it donot insert the record when i execute the query from .php file but if i echo query and copy its output from browser and paste it inside phpmyadmin SQL window it works fine
$insert_device_order = "START TRANSACTION;
INSERT INTO request
VALUES ('', '', '$spoc_id', '$spoc_username', '', '', 'Device', 'Submitted','$spoc_id' );
INSERT INTO devices
VALUES ( '', LAST_INSERT_ID( ) , '$device_msisdn', '$device_payment','$device_offer', '$device_device' );
COMMIT;";
$result = mysql_query($insert_device_order);
if($result){header("Location: addDevices2.php");}else{ echo "cannot insert";}
i am unable to find the issue as i checked my config file is also included at the top.
i use this method to to over come this issue but it also do not worked
mysql_query("START TRANSACTION");
mysql_query("INSERT INTO request VALUES ('', '', '$spoc_id', '$spoc_username', '', '', 'Device', 'Submitted','$spoc_id' )");
mysql_query("INSERT INTO devices VALUES ( '', LAST_INSERT_ID( ) , '$device_msisdn', '$device_payment','$device_offer', '$device_device' )");
mysql_query('COMMIT');