So... this is my code:
$paymentType=$_POST["paymentType"]; // in the first two lines the $_POST data is copied into normal variables to make it easier to handle
$paymentMethod=$_POST["paymentMethod"];
$amount=$_POST["amount"];
$date=$_POST["date"];
$other=$_POST["other"];
$mysqlserver="localhost"; // in the next six lines the connection to the server is set up just like before and the database is chosen
$mysqlusername="jakedean";
$mysqlpassword="jakedean";
$link=mysql_connect($mysqlserver, $mysqlusername, $mysqlpassword) or die ("Error connecting to mysql server: ".mysql_error());
$dbname = 'jakedean';
mysql_select_db($dbname, $link) or die ("Error selecting specified database on mysql server: ".mysql_error());
// the query which inserts the new data (from the variables) is set up and run
$addPaymentquery="INSERT INTO TBL_payments
(paymentType, paymentMethod, amount, date, other)
VALUES
('$paymentType', '$paymentMethod', '$amount', '$date', '$other')";
mysql_query($addPaymentquery) or die("Query to insert new Payment into TBL_payments failed with this error: ".mysql_error());
echo "<p class=\"thicker2\">You added a new Payment to Person ID:$personId! The Payment information added was:</p><p class=\"bold\">Payment Type:</p> <p class=\"thicker\">$paymentType</p>
<p class=\"bold\">Payment Method:</p> <p class=\"thicker\">$paymentMethod</p><p class=\"bold\">Amount Paid:</p> <p class=\"thicker\">$amount</p><p class=\"bold\">Date of Payment:</p> <p class=\"thicker\">$date</p>
<p class=\"bold\">Additional Comments:</p> <p class=\"thicker\">$other</p>";
The error is a combination of undefined indexes' and a cannot update a child row because I've related the sql tables wrong...
Error message:
I don't know if this helps, but inside my database there are some fields in different tables which have the same name...
I've been trying to fix this for days but I can't figure it out, this is my first database I've built! Appreciate any responses!