Welcome Guest, Not a member yet? Register   Sign In
Mysql error:|
#1

[eluser]Young Caveman[/eluser]
Hi!
I put this in a module:

Code:
$query = $this->db->query('SELECT * FROM e-mail WHERE e-mail = '.$mail);

but it outputs:

Code:
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 '-mail WHERE 'e-mail' = [email protected]' at line 1

SELECT * FROM e-mail WHERE 'e-mail' = [email protected]

I can't understand why cause i always did like that when querying the db. :|
Thanks in advance guys.

Don ~ Alberto
#2

[eluser]_asdf[/eluser]
It sounds like CI is being ('over')-zealous in its escaping fields/columns, because of your bad practice. Naming tables and columns the same = bad idea. Naming tables or columns after reserved words = bad idea. Both of these are possible, but seriously better off avoided.
#3

[eluser]Young Caveman[/eluser]
[quote author="_asdf" date="1209159400"]It sounds like CI is being ('over')-zealous in its escaping fields/columns, because of your bad practice. Naming tables and columns the same = bad idea. Naming tables or columns after reserved words = bad idea. Both of these are possible, but seriously better off avoided.[/quote]

Can't understand what "reserved words" are :|
#4

[eluser]TheFuzzy0ne[/eluser]
[quote author="Sensuous." date="1209156958"]Hi!
I put this in a module:

Code:
$query = $this->db->query('SELECT * FROM e-mail WHERE e-mail = '.$mail);

but it outputs:

Code:
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 '-mail WHERE 'e-mail' = [email protected]' at line 1

SELECT * FROM e-mail WHERE 'e-mail' = [email protected]

I can't understand why cause i always did like that when querying the db. :|
Thanks in advance guys.

Don ~ Alberto[/quote]

Error 1064 is simply a parse error.

Naming tables/columns with underscores instead of hyphens is much better practice. You may find that encapsulating the table name in quotes may help.

I would advise that you just change the table/column name(s) to "email" or "e_mail".
#5

[eluser]Young Caveman[/eluser]
[quote author="TheFuzzy0ne" date="1209164822"]

Error 1064 is simply a parse error.

Naming tables/columns with underscores instead of hyphens is much better practice. You may find that encapsulating the table name in quotes may help.

I would advise that you just change the table/column name(s) to "email" or "e_mail".[/quote]

Thanks it works. :-)




Theme © iAndrew 2016 - Forum software by © MyBB