Skip to content
Advertisement

php inserts only last array record into sql

I have working code, which inserts data into csv file. Here is a part of it:

JavaScript

Instead of csv, i would like it to insert data into mysql database, so i have simply changed the code to:

JavaScript

Only the last record is saved into the persons table. There are no errors, but all the previous records except last are not inserted. Why?

Advertisement

Answer

The reason why it doesn’t work is because you never execute your SQL query anywhere.

To execute the query you should first prepare the statement and then bind the params and execute.

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement