T_CONSTANT_ENCAPSED_STRING - 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: T_CONSTANT_ENCAPSED_STRING (/showthread.php?tid=54529) |
T_CONSTANT_ENCAPSED_STRING - El Forum - 09-12-2012 [eluser]xtremer360[/eluser] Code: $this->db->select("DATE_FORMAT(".$this->master_model->news_articles_table.".news_article_posting_date, '%M %D, %Y') AS news_article_posting_date", FALSE); Any idea why I'm getting a T_CONSTANT_ENCAPSED_STRING error with these two lines? T_CONSTANT_ENCAPSED_STRING - El Forum - 09-12-2012 [eluser]yacman[/eluser] Try it like this: Code: $this->db->select("DATE_FORMAT({$this->master_model->news_articles_table}.news_article_posting_date, '%M %D, %Y') AS news_article_posting_date", FALSE); T_CONSTANT_ENCAPSED_STRING - El Forum - 09-12-2012 [eluser]xtremer360[/eluser] Same result. T_CONSTANT_ENCAPSED_STRING - El Forum - 09-12-2012 [eluser]PhilTem[/eluser] I don't get any T_CONSTANT_ENCAPSED_STRING errors using your code. Are you sure it's these lines? T_CONSTANT_ENCAPSED_STRING - El Forum - 09-12-2012 [eluser]CroNiX[/eluser] What query does it produce? T_CONSTANT_ENCAPSED_STRING - El Forum - 09-12-2012 [eluser]xtremer360[/eluser] Yeah my bad it was the line below it and I just didn't see it the first couple of times looking at it. Sorry guys. T_CONSTANT_ENCAPSED_STRING - El Forum - 09-12-2012 [eluser]xtremer360[/eluser] I take that back. 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 '.last_name) AS author, `news_article_categories`.`news_article_category_name` FR' at line 1 SELECT `news_articles`.`news_article_id`, `news_articles`.`news_article_title`, DATE_FORMAT(news_articles.news_article_posting_date, '%M %D, %Y') AS news_article_posting_date, CONCAT_WS(' ', users.first_name.users.last_name) AS author, `news_article_categories`.`news_article_category_name` FROM (`news_articles`) JOIN `users` ON `users`.`user_id` =`news_articles`.`news_article_author_id` JOIN `news_article_categories` ON `news_article_categories`.`news_article_category_id` =`news_articles`.`news_article_category_id` T_CONSTANT_ENCAPSED_STRING - El Forum - 09-12-2012 [eluser]CroNiX[/eluser] you have an extra period in your CONCAT_WS that is producing this in the sql: users.first_name.users.last_name should be users.first_name, users.last_name T_CONSTANT_ENCAPSED_STRING - El Forum - 09-12-2012 [eluser]xtremer360[/eluser] Code: $this->db->select("CONCAT_WS(' ', ".$this->master_model->users_table.".first_name", $this->master_model->users_table.".last_name) AS author", FALSE); Tried this and I'm still getting a syntax error. |