Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

Error in Treehouse page?

Hi - I'm completing the SQL / PHP course and I'm stuck on the SELECT statement... or rather it's stuck?

I enter "SELECT 'price', 'name' FROM products" and the result says I've failed and shows this error...

f1705544-0c3f-4631-a4c4-d5185a161a1f.rb:37:in eval': undefined methodto_a' for # (NoMethodError) from f1705544-0c3f-4631-a4c4-d5185a161a1f.rb:37:in eval' from f1705544-0c3f-4631-a4c4-d5185a161a1f.rb:37:in'

SO... how do I complete the module?

2 Answers

Try removing the single quotes from the field names:

"SELECT price, name FROM products"

OK, that got it. Odd thing to have to do though, no?

Anyhoo - all is well, cheers Alex.

Because you wrapped the field names in quotes it is then treating the value as a string literal instead of an actual fields.

Say you had a WHERE clause and you wanted it to be equal to some value you would wrap it there:

"SELECT price, name FROM products WHERE name='apple' "

What a douche... work THEN beer next time. Cheers Alex!

:)