I’m looking at the loop structure here and I see that the variable $dbdataentry is set to hold an SQL INSERT statement for each line of the CSV that is read, but the statement is only used OUTSIDE of the loop - that is, only the last line of the CSV would ever be inserted using this code. In plain terms, I think the line $result = pg_query($dbconnect, $dbdataentry); should be inside the where-loop braces, not outside… You code does no error checking - what is the value of $result after this? It may be that there is no ‘error’ as such. The INSERT runs correctly for what you have asked it to do unless there is some database constraint on the value in that table like the id or email should be unique. Whatever the SELECT statement to get the number of rows returns it what was inserted - I suspect that one row should be added to the table every time the code is run, and it will be values from the last row of the CSV. Is this what you observe? When asking for help, it always helps if you explain what you actually observe happening with your code, and not just the thing you expected to happen, or what didn’t happen. Logs are not everything - they only contain what was reported and often only actual errors, not successful (but wrong) operations. Use the database tools available outside of PHP (e.g. phpPgAdmin, pgAdmin, even just the psql command-line) to check what the database table contains after the code runs. If you don’t know how to do this then you may not yet be ready to write database applications. If you do know how to do this, you could show us the results… Pete
|