PHPFAN10 Posted January 19, 2011 Share Posted January 19, 2011 Hello Newbie to the forum here and found you via Google, looks like a great site and forum hence why i registered and to get help when needed. Can someone please tell me if the following code means if the query fails in anyway like when updating DB or any other failure it will display the error message else if query updated successfully it will go to else and continue as normal? Reason i ask as not sure if it means if update query fails display error else query ok so continue or it will fail if it cannot connect to db or typo in query itself? I think it would fail if any mysql error happens on query but not sure if it means would go to error if failed on anything or just certain things. Thanks for any help. I know it's not the full code but it's this part i want to understand. # Databse query $query = mysql_query("SELECT id, admin, username, first_name, last_name, email FROM `users` WHERE username = '$username' AND password = '$password' LIMIT 1"); # Check login query if(!$query){ echo 'Oops'; } else { echo 'Done!'; } Link to comment https://forums.phpfreaks.com/topic/225027-does-this-code-mean-what-i-think-it-does/ Share on other sites More sharing options...
TOA Posted January 19, 2011 Share Posted January 19, 2011 You are correct. If there is no result from the query, which would encompass any of those failures you mentioned, it would say Oops Link to comment https://forums.phpfreaks.com/topic/225027-does-this-code-mean-what-i-think-it-does/#findComment-1162242 Share on other sites More sharing options...
PHPFAN10 Posted January 19, 2011 Author Share Posted January 19, 2011 Thanks for the super quick reply. I thought it would display oops if any mysql error happened but was not sure, well am now of course because of your help SOLVED Thanks PHPFAN2010 Link to comment https://forums.phpfreaks.com/topic/225027-does-this-code-mean-what-i-think-it-does/#findComment-1162246 Share on other sites More sharing options...
dendic Posted January 20, 2011 Share Posted January 20, 2011 Jes,you are correct...If there is no result from the query, which would encompass any of those failures you mentioned, it would say Ops,Ops... Link to comment https://forums.phpfreaks.com/topic/225027-does-this-code-mean-what-i-think-it-does/#findComment-1162373 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.