Skip to content
Advertisement

converting to PDO, problems

So I am working on converting an old tutorial I did a while back from mySQL to PDO. This way I can better understand the concepts. I seem to of run into a wall however. The following function is giving me an error

JavaScript

this is where I am calling the function

JavaScript

this is my error

JavaScript

So more specifically this line as commented on in the function above

JavaScript

I don’t see why this line is the causing this error. I also have no idea how to fix it. Any help is appreciated.

Advertisement

Answer

func_get_args() returns all the arguments of the function. You unset() the 0th element, but you have two elements you need to remove from the start of the args. I show an example below of using array_slice() to start with element 2.

Also, your function has a glaring SQL injection vulnerability, interpolating the list of column names directly into your SQL select-list. You should allowlist the input against a list of all the columns of your users table, to make sure the input doesn’t contain something you don’t expect.

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