When we create some code for fetching some data from the database (who is a beginner in PHP), on first-time code or without practicing of writing the code getting some errors, like nothing is showing on page or data is not coming as our expectation.
On that time we are irritated because of not getting any error and look like all code are correct.
At that time I use some steps to identify problems on the code.
1. If error at the time of posting data from a form,
1. <strong>Check $_POST is in capital letters.
2. Print $_POST or posted value using echo $_POST['feild_name'].
3. Check name attribute on the form and posted name, both are same or not.
</strong></code> These are some kind of steps which I usually use for solving data submitting problems. 2. If you have a data from the form but not inserted on the database. 1. Check the data field name on the database and insert query, where you use them name of the field, both are same or not. 2. Second is important and best step for solving the problem is, print the MySQL query, like that <strong><code>echo "SELECT * FROM table_name WHERE id=$id";
O/P: SELECT `feild1`,`feild2`,`feild3` FROM table WHERE id=5;</code> </strong> Copy that output and paste on PHPMYADMIN Sql screen and Click GO button, if there is any error you can find and solve very easily.
Was this article helpful?