I ran into a problem with performing multiple queries in my DB. Each time I query the DB with just a single line of SQL, it stores that data in the DB just fine. But when I try to execute a multi-line query, it becomes a problem. I tried using mysqli_multi_query as well, but still no luck. And I even tried to make the SQL statement into one string, and that also didn't work. I've posted my code below, and any help would be greatly appreciated.
P.S. This is a SPA (Single Paged App) so I cant really do the usual "echo this error out" if I'm getting thrown a error. Instead I'm just having it print the error to a file
Connection.php
<?php
//File used for connecting to a database
//Location of the DB
$dbhost = 'localhost';
//User name of the DB
$dbuser = 'root';
//Password of the DB
$dbpass ='';
//Name of the DB
$db = 'structures';
// Connection to the database SERVER. Parameters include: Host, User, and Password
$conn = mysqli_connect($dbhost,$dbuser,$dbpass,$db);
?>
Go2.php
<?php
include 'connection.php';
$firstName = $_POST["firstName"];
$middleName = $_POST["middleName"];
$lastName = $_POST["lastName"];
$NetIDQuest = $_POST["NetIDQuest"];
$NetID = $_POST["NetID"];
$InstQuest = $_POST["InstQuest"];
$Entity = $_POST["Entity"];
$Consulting = $_POST["Consulting"];
$Reimbursed = $_POST["Reimbursed"];
$Royalties = $_POST["Royalties"];
$Equity = $_POST["Equity"];
$PublicQuest = $_POST["PublicQuest"];
$PublicVal = $_POST["PublicVal"];
$SignConfirm = $_POST["SignConfirm"];
$sql = "INSERT INTO user_info(NetID) SELECT NetID from user where NetID = '$NetID';"; // Insert the FK of NetID into the user_signature table before update
$sql. = "UPDATE user_info SET FirstName = '$firstName', MiddleName = '$middleName', LastName = '$lastName' WHERE NetID = '$NetID';"; //Update the User_Info Table
mysqli_multi_query($conn,$sql) or die (mysql_error());
/*
$sql = "INSERT INTO user_signature(NetID) SELECT NetID from user_info where NetID = '$NetID';"; // Insert the FK of NetID into the user_signature table before update
mysql_query($sql) or die (mysql_error());
$sql = "UPDATE user_signature SET Signature = '$SignConfirm' WHERE NetID = '$NetID';"; // Update the user_signature table
mysql_query($sql) or die (mysql_error());
$sql = "INSERT INTO financial(NetID) SELECT NetID from user_info where NetID = '$NetID';";
mysql_query($sql) or die (mysql_error());
*/
$myfile = fopen("newfile.txt", "w") or die("Unable to open file!");
$txt = mysqli_error($conn);
fwrite($myfile, $txt);
fclose($myfile);
?>