Tuesday 9 May 2017

Checking mysql for a name, but console logs error

When running the code below, the console logs "There is an error", even though I know that there is a name equal to 'conversation_receiver'. There aren't any syntax problems, so I can't see what I've done wrong.

client.on("checkConversation", function(name, fn){
                var match = false;
        connection.query('SELECT * FROM `conversations` WHERE `conversation_receiver` = name', function(error, results, fields){
                        if (error) {
                                console.log("There is an error");
                        }
                        else if(results) {
                                match = true;
                                console.log("There are results");
                        } else {
                                console.log("There are fields");
                        }
                        
                });
                fn({result: match});
        });


via JonasSH

No comments:

Post a Comment