![]() |
SQL question - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: SQL question (/showthread.php?tid=41660) |
SQL question - El Forum - 05-13-2011 [eluser]theknight[/eluser] Code: $this->db->select("Contacts.Id, CAST(FirstName AS TEXT) as FirstName, CAST(Surname AS TEXT) as Surname, CAST(Gender AS TEXT) as Gender, CAST(MobilePhoneNumber AS TEXT) as MobilePhoneNumber, CAST(WorkPhoneNumber AS TEXT) as WorkPhoneNumber, CAST(Email AS TEXT) as Email, UserAccount_Id, Address_Id"); Returns this error: Invalid column name 'dummy'. SELECT Contacts.Id, CAST(FirstName AS TEXT) as FirstName, CAST(Surname AS TEXT) as Surname, CAST(Gender AS TEXT) as Gender, CAST(MobilePhoneNumber AS TEXT) as MobilePhoneNumber, CAST(WorkPhoneNumber AS TEXT) as WorkPhoneNumber, CAST(Email AS TEXT) as Email, UserAccount_Id, Address_Id FROM UserAccounts JOIN Contacts ON Contacts.UserAccount_Id=UserAccounts.Id WHERE username=dummy why is it getting an invalid column name? SQL question - El Forum - 05-13-2011 [eluser]Jocke[/eluser] You need to add some quotes. username = 'dummy' SQL question - El Forum - 05-13-2011 [eluser]theknight[/eluser] how do I wrap the quotes around the username variable in the SQL statement? SQL question - El Forum - 05-13-2011 [eluser]Jocke[/eluser] I guess you could try: Code: $usernameCheck = $this->db->get_where($this->table, "username='". $username ."'"); Not to sure about all different types of statements you have. Would make more sence to me with one SQL statement but hey, it might work! ![]() SQL question - El Forum - 05-13-2011 [eluser]theknight[/eluser] Thanks mate, that worked perfectly. My script is now working ![]() |