I’ve read a lot of documentation tonight, can’t see why this isn’t working. Obviously something I’m missing.
$newstr = "18,19";
$defid = 1;
$table = "wp_tablename";
$data = "array( 'somecol' => '".$newstr."' )";
$where = "array( 'id' => ".$defid." )";
if ($wpdb->update( $table, $data, $where) === FALSE)
{
echo "failure";
}
else
{
echo "success";
}
Comes up false every time. Any clues? What am i missing here? I did try using format_where and that didn’t work either.
you’re creating the
$data
and$where
values as strings, not arrays.this:
should be:
Don’t use ‘identical’ operator
===
, use simplyif ($wpdb->update(.......) {.......}
because a boolean value is passed on to a control structure. See PHP Comparison Operators. See Milo’s answer for strings and arrays.