3

I have table with colums id, name, email, message, phone, links and login. Login can be null(empty).

Its my sql request:

$dbh = new PDO("mysql:host=$dbHost;dbname=$dbName", $dbUser, $dbPassword); $sth = $dbh->query('SELECT * FROM `form` WHERE login NOT NULL '); $sth->setFetchMode(PDO::FETCH_ASSOC); 

whith this error

 Call to a member function setFetchMode() on a non-object 

Its error with "WHERE login NOT NULL", i know. How me correctly make this request?

2
  • 1
    You are getting a query error. use IS NOT NULL instead of NOT NULL Commented Jan 28, 2013 at 17:22
  • 1
    never assume a query has succeeded. ALWAYS check the return values from a DB operation. There's exactly ONE way for queries to succeed, and far far far too many ways for things to fail. Commented Jan 28, 2013 at 17:28

3 Answers 3

10

missing an IS

SELECT * FROM `form` WHERE login IS NOT NULL 
Sign up to request clarification or add additional context in comments.

Comments

1

Try IS NOT NULL instead of just NOT NULL

Comments

0

You're looking for:

"WHERE login IS NOT NULL"

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.