The only challenge is identifying whether the error comes from PHP or from the SQL server.

Open sqlinsertwithcode.php and save it as sqlerrors.php then change INSERT to INERT.  Save and try and you should see something like this:

Error inserting: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'INERT INTO first (personalName, familyName) VALUES ('Fred', 'Bloggs')' at line 1

Note that the first two words come from your code (see the bit immediately after or die) and not from the server.  That is why it was put there.  Even if you do not understand the technical error you can see your bit and know which line is saying there is an error.  When writing the die() function make sure that you write an error message which means something to you and helps you to find the line of code to check.  Maybe make each message completely unique and recognisable. 

Notice that the part of the message which comes from the server claims that the error is on line 1.  That is because the error comes from the SQL server which only receives the query.  The error is on line 1 of that query and not line 1 of your PHP.

If you find the error hard to understand don't worry SQL errors are not always helpful.  However, if you know which query is broken that helps.  The error then says there is an error in your SQL syntax but that could be almost anything.  Check spelling and punctuation first.  Then make sure you have single quotes around text and not around table and field names.

If you first look for whether it is a PHP error or an SQL error the rest will be easier.