Here is another post to help out PHP beginners.
So you created your connection object, wrote your query, created a statement object, bound your variables to protect yourself against injection attacks etc. Now you execute your query and wanna see if the execution was successful.
How do you know if the query was successfully executed on the database? Keep reading. It is very easy 🙂
How to check if Insert query succeeded in PHP
To check if your query was executed successfully you need to assign the result of statement execution to a variable and check that variable with an if condition. Assuming $stmt is our statement object and it is ready to be executed see the code below:
$result = $stmt->execute();
//stmt executed successfully.
//stmt execution failed. handle it here.
So once we assign the execution result to $result variable and check it with an if condition we will be able to see if the query was executed successfully or not in PHP.
Hope this helps.