CodeIgniter Forums

Full Version: spaces in MySQL columns
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

I'm having trouble inserting a record using the Active Record Class when the column name has a space in it. I've tried using brackets & '' but its not working as expected:


$data = array('Constituent Name' => $this->input->post('fullName', TRUE))

$this->db->insert('mis', $data);

This is actually the first time I've seen spaces in a table's filed name I don't know how to fix this...

Any help would be greatly appreciated. Thanks!

El Forum

change the table name

El Forum

its not the table name that is the problem, its the field in the table that has the space - and I can't change the name because the database is used by other applications which I have no control over....

El Forum

[eluser]Randy Casburn[/eluser]
that's an unfortunate poor design that's been thrust upon you.

You must use backticks to surround your column name. You'll also have to finagle those through your PHP and JS string sanity and validation checks.

Best of luck.