Welcome Guest, Not a member yet? Register   Sign In
Error number: 1064
#1

[eluser]Gijs Bloemen[/eluser]
Hi,

I get an error number: 1064, in the error you can see this:

Quote:Error Number: 1064

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 ':%i) AS laatste_reactie_format FROM (`forum_boards`) JOIN `users` ON `forum_boar' at line 1

SELECT `board_id`, `board_titel`, `omschrijving`, `laatste_reactie`, `laatste_poster_id`, `laatste_topic_id`, `board_aantal_topics`, `board_aantal_reacties`, dateformat(laatste_reactie, `%d-%c-%m` %h:%i) AS laatste_reactie_format FROM (`forum_boards`) JOIN `users` ON `forum_boards`.`laatste_poster_id` = `users`.`id`

The code in my model about this is the following:

Code:
function get_all_boards() {
        
        $this->db->select('board_id, board_titel, omschrijving, laatste_reactie, laatste_poster_id, laatste_topic_id, board_aantal_topics,
                           board_aantal_reacties, dateformat(laatste_reactie, %d-%c-%m %h:%i) AS laatste_reactie_format');
        $this->db->from('forum_boards');
        $this->db->join('users', 'forum_boards.laatste_poster_id = users.id');
        
        $query    =    $this->db->get();
        
        return $query;
        
    }

I got this problem since I use the dateformat function.

Regards,
Gijs Bloemen
#2

[eluser]wowdezign[/eluser]
[quote author="Gijs Bloemen" date="1248755105"]
Code:
$this->db->select('board_id, board_titel, omschrijving, laatste_reactie, laatste_poster_id, laatste_topic_id, board_aantal_topics,
                           board_aantal_reacties, dateformat(laatste_reactie, %d-%c-%m %h:%i) AS laatste_reactie_format');
        $this->db->from('forum_boards');
        $this->db->join('users', 'forum_boards.laatste_poster_id = users.id');
        
        $query    =    $this->db->get();
        
        return $query;
        
    }
[/quote]

it looks like this:
dateformat(laatste_reactie, %d-%c-%m %h:%i)

Should be:
dateformat(laatste_reactie, '%d-%c-%m %h:%i')

There may be other things but that is what jumped out at me.
#3

[eluser]ggoforth[/eluser]
You need to pass in a second parameter to your select statements of "false". This will tell codeigniter not to protect table and field names (backticks). This is your problem. Just add false as a second parameter into you selects and your problems will be solved.

Greg




Theme © iAndrew 2016 - Forum software by © MyBB