Error query PDO

Asked

Viewed 40 times

-3

I have the following code:

@$import = $dbconn->prepare("UPDATE t SET");

if(a <> "")
{
$import .= "teste2= '$a', teste= '$b', ";
...

It returns this error:

Catchable fatal error: Object of class PDOStatement could not be converted to string in

The error is at the line where I query the variable, When I run the query in the database works normally.

1 answer

0

I think it would be something +/- like this, you can concatenate text with text and not text with object...

$import = "UPDATE t SET ";

if(a <> ""){
  $import .= "teste2 = '$a', teste= '$b' ";
}

$dbconn->prepare($import);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.