If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Enjoy an ad free experience by logging in. Not a member yet? Register.

With any luck at all, you will then get a better diagnostic error message.

In this case, you would like get an error message like this:

Code:

ERROR 1064 (42000): 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 ''test'' at line 1

You will soon learn that this message puts '...' around your actual error. So when you see

Code:

''test''

you remove the outer apostrophes and you know that the error is in the code

Code:

'test'

I'll save you the trouble of browsing through the MYSQL docs: ANY time you put something in APOSTROPHES, that something becomes a *STRING* to MySQL.

And you can *NOT* select anything from a *STRING*.

You must select from a table NAME.

In other words, if you had simply done

Code:

SELECT * FROM test

you would not get that error!

*PROBABLY* you don't see the difference between apostrophes ('...') and back ticks (`...`). A ` back tick is the character that shares the keyboard key with the ~ tilde. And yes, MySQL allows you to put back ticks--*NOT* apostrophes--around table and field names.

hi mate thanks for your response.
I initially did put no variable and i understand there is no point but the code is exactly the same in theory, i was just trying different ways to identify the problem.
I have amended my code based on your suggestion and I am still getting a "Database not selected" error when there IS a table in my database called test and it has one field called Name so i am lost now.