The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End function in php Re: function in php


Note that simply adding an argument for the table name wouldn’t work anyway – not without making the code a lot more complex/ less secure, that is.

You can’t parameterize table names in a prepared statement.

If you switch to individual queries, you’ll have to handle sanitization yourself (less reliable), and it will still only work if the two tables had the same columns (and if that’s the case, why are they *different* tables?).

What you need to consider is that storing information is not a “generic” task – using a database is less like throwing papers in a file folder and more like filling out a form. You can’t just send the info to the DB randomly and expect it to be stored properly.

If you do manage to write a single function to handle “any” table, it’s going to be large, convoluted, inefficient, and buggy.