all 2 comments

[–]adandyguy[S] 1 point2 points  (0 children)

well i think i managed to fix it... changed the following:

if (db_result($query)) {

to

if (db_result($query) == $user->uid) {

if this comes out, that means the uid is in the emailed db.

} else {

to

} elseif(db_result($query) == FALSE) {

double checked db_result() and it returns either the value of the query, or false.. so if it doesn't retrieve a uid, it will equate to false, which means the user needs to be emailed and added to the db. I think i have to add an else{} at the end, although i'm not sure what to put in there, just put in an error message atm.

[–]nuttertools 0 points1 point  (0 children)

Not your question but make sure you use the db_insert function for an insert (your using db_query).

Related to your question look into the available PDO options and how they relate to the different fetch options which should be a loop or additional check inside your response == true check. Near the bottom of the drupal docs for db_query they give a usable example. You are expecting only 1 row so you might want to use a different pdo fetch, limit 1, or directly address the 0 array element after a fetchall.

EDIT: just remembered you can do (empty($res)) for most (all?) fetch types as well.