Syntax error on trying to update empty column row values
Question by Woistmeinhandy
I am trying to add a keyword to empty column / row values in my database but I can’t get it to work. I am getting a syntax error.
Here is the code:
$sql[$handle]['sql'] =
'SELECT IF(char_length('.$field.')>0, '.$field.',''.$replace.'') AS '.$field.'
FROM '.$table.'')';
Answer by Starx
You have escaped a quote extra on the end.
$sql[$handle]['sql'] =
'SELECT IF(char_length('.$field.')>0, '.$field.',''.$replace.'') AS '.$field.'
FROM '.$table.'')';
// ^ Right here
Next, you have an extra bracket )
at the end [Credit: Registered User]
$sql[$handle]['sql'] =
'SELECT IF(char_length('.$field.')>0, '.$field.',''.$replace.'') AS '.$field.'
FROM '.$table.')';
// ^ Right here
Solution: Remove them and you should get something like this to work:
$sql[$handle]['sql'] = 'SELECT IF(char_length('.$field.')>0, '.$field.',''.$replace.'') AS '.$field.' FROM '.$table;