ghurty Posted October 26, 2009 Share Posted October 26, 2009 Why is this not working? $query = "SELECT * FROM `users` WHERE `userid` = " . $USERID AND `pin` = " . $PIN; $result = mysql_query($query) or die("Web site query failed"); When I all I have is: $query = "SELECT * FROM `users` WHERE `userid` = " . $USERID; $result = mysql_query($query) or die("Web site query failed"); It does work. But when I ad the PIN, it just fails. I have the variable $PIN assigned and I have a field called pin. Thanks Link to comment https://forums.phpfreaks.com/topic/179011-why-is-this-query-failing/ Share on other sites More sharing options...
mikesta707 Posted October 26, 2009 Share Posted October 26, 2009 you are concatenating incorrectly. you should use an editor with syntax highlighting, because the error will become very apparent. $query = "SELECT * FROM `users` WHERE `userid` = " . $USERID AND `pin` = " . $PIN;//bad query $query = "SELECT * FROM `users` WHERE `userid` = " . $USERID . " AND `pin` = " . $PIN; //fixed Link to comment https://forums.phpfreaks.com/topic/179011-why-is-this-query-failing/#findComment-944452 Share on other sites More sharing options...
trq Posted October 26, 2009 Share Posted October 26, 2009 Are both userid and pin non numeric data types? Link to comment https://forums.phpfreaks.com/topic/179011-why-is-this-query-failing/#findComment-944453 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.