centenial Posted June 10, 2006 Share Posted June 10, 2006 Is there a way to do this?If MySQL query was executed successfully - Display success message.Else... Display error message.There must be an easy way to do this, but I don't know how to tell the script if the query was executed successfully.Please help? Quote Link to comment https://forums.phpfreaks.com/topic/11670-if-sql-was-executed-successfully-display-message/ Share on other sites More sharing options...
poirot Posted June 10, 2006 Share Posted June 10, 2006 [code]$sql = "SELECT something FROM sometable";$result = mysql_query($query);if ($result === false) { echo 'Error: ' .mysql_error();} else { echo 'Success';}[/code][!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]For SELECT, SHOW, DESCRIBE or EXPLAIN statements, mysql_query() returns a resource on success, and FALSE on error. For other type of SQL statements, UPDATE, DELETE, DROP, etc, mysql_query() returns TRUE on success and FALSE on error. [/quote] Quote Link to comment https://forums.phpfreaks.com/topic/11670-if-sql-was-executed-successfully-display-message/#findComment-44122 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.