Welcome Guest, Not a member yet? Register   Sign In
SQL question
#1

[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");
        //joins the two tables
        $this->db->join('Contacts', 'Contacts.UserAccount_Id=UserAccounts.Id');
        //User Account, get username
        $usernameCheck = $this->db->get_where($this->table, 'username='.$username);

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?
#2

[eluser]Jocke[/eluser]
You need to add some quotes. username = 'dummy'
#3

[eluser]theknight[/eluser]
how do I wrap the quotes around the username variable in the SQL statement?
#4

[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! Smile
#5

[eluser]theknight[/eluser]
Thanks mate, that worked perfectly.

My script is now working Smile




Theme © iAndrew 2016 - Forum software by © MyBB