The following is throwing a syntax error. The entire query works in a MySQL client with literals, but breaks down when passing from PHP. In PHP, each query works if submitted separately, but not if within START and COMMIT.
The error:
1064: You have an error in your SQL syntax; check the manual ...etc...right
syntax to use near 'INSERT INTO user_degrees (user_id, degree_id, acadcat_id
, inst_id) VALUES (' at line 2
Query:
$query="START TRANSACTION;
INSERT INTO user_degrees (user_id, degree_id, acadcat_id, inst_id)
VALUES ((SELECT id FROM users WHERE users.username = '$user')
, '$degreeid', '$studyfocus', '$institution');
UPDATE users
SET degree".$dnum." = (SELECT LAST_INSERT_ID())
WHERE username = '$user';
COMMIT;";
All the $vars are class properties and pass integers, except for $user, which passes a username session variable. $dnum is used to change column names between instances of the class and I might be concatenating it incorrectly within MySQL.