0

I'm trying to insert the same data into two separate tables though I'm having issues with the syntax and I'm not sure how to correctly format everything. I know the queries work when run individually though when I try to run it as below I either get syntax errors or the last query runs and that's it.

$sql = "BEGIN TRANSACTION";
        "INSERT INTO users (user_name, first_name, last_name, email, password, hash) " 
        . "VALUES ('$user_name','$first_name','$last_name','$email','$password', '$hash')";
        "INSERT INTO tbluser (user_name, first_name, last_name, email, password, hash) " 
        . "VALUES ('$user_name','$first_name','$last_name','$email','$password', '$hash')";
        "COMMIT TRANSACTION";
BR1888
  • 43
  • 7
  • What language is this for? The first problem might be that you're not concatenating (all) the string literals, at least if one assumes that it's a language using a C like syntax where `;` ends a line. And the next thing you should do is probably to look for parameterized queries in that language. – sticky bit Apr 22 '19 at 03:15
  • https://stackoverflow.com/questions/12502032/insert-multiple-rows-with-one-query-mysql – M.Hemant Apr 22 '19 at 03:30
  • Please mention your syntax error. And why . (dot) is in your SQL query before values. – Jeet Kumar Apr 22 '19 at 03:58
  • Learn to use parameters! Don't munge query strings with constant values. – Gordon Linoff Apr 22 '19 at 11:38

0 Answers0