Skip to content Skip to sidebar Skip to footer

Pdo::query() Expects Parameter 1 To Be String, Object Given Warning

Im having a little issue with PDO. I posted another question about 2 minutes ago an that was answered pretty quickly but now I have another error. Here is the code:

Solution 1:

You don't need to call PDO::query(). For a prepared statement, you call PDO::prepare(), then PDOStatement::execute() performs the query and you can retrieve the result using PDOStatement::fetch*.

PDO::query() is only used for dynamic SQL; it takes as its argument the string SQL query statement eg. SELECT statement, &c.

Solution 2:

@rizier123 answered my question.

I just needed to delete the if statement and add quotes to the row data.

Thanks @rizier123

Post a Comment for "Pdo::query() Expects Parameter 1 To Be String, Object Given Warning"