I am trying to use PHP to update column data but I am receiving a division by zero error.
mysql_query('UPDATE personas SET toolbar_id=\'' . $result . '\' WHERE download_ff LIKE concat('%',\'' . $result . '\','%')');
echo mysql_error($link);
printf("Records inserted: %d\n", mysql_affected_rows());
Ive tried a few ways to concat the $result but it is all resulting in a division by zero error. Help!
Your problem is right here:
The
%ends out outside the string so PHP is interpreting it as a modulus operation and the strings on both sides of the modulus will be zeros in a numeric context, the result is that you’re trying to0 % 0and you get your “division by zero” error.Try escaping the inner single quotes:
Or, create a
$like_resultin your PHP that includes the percent signs in the string and then do this:You are using
mysql_real_escape_stringtoo, right?