CodeIgniter Forums
Replace comma[,] with space[''] - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Replace comma[,] with space[''] (/showthread.php?tid=47722)



Replace comma[,] with space[''] - El Forum - 12-19-2011

[eluser]Unknown[/eluser]
Hi ,


$classlist=array('AAA','AA','A','B','C','D','E');
$query=$this->db->select("class, sum(replace(fieldname),',','') as field")
->from($this->table1)
->group_by('class')
->where('idtfieldname',$subid)
->where_in('class',$classlist)
->get();
------------------------------------------------------------------------------------------
in above code i want to replace the comma[,] with space['']. manually i try this code it is working fine
but when i try in codeigniter`. i am getting this error ..




<h1>A Database Error Occurred</h1>
<p>Error Number: 1064</p><p>You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' `''))` as field
FROM (`tablename`)
WHERE `idtfieldname` = '22'
AND `cla' at line 1</p><p>SELECT `class`, sum(replace(fieldname, `'`, `'`, `''))` as field
FROM (`tbuilding`)
WHERE `idtfieldname` = '22'
AND `class` IN ('AAA', 'AA', 'A', 'B', 'C', 'GOV', 'WRHS')
GROUP BY `class`</p> </div>

help me ....to solve this my email id is [email protected]

thanks in advance ...