Skip to content
Advertisement

Can read Data from mysql database but cant write data into the database Using PHP 5.6 on Ubuntu 16.04?

I have a PHP 5.6 project, when I run it on localhost in windows/xampp it works perfectly fine.But when I use it in ubuntu/apache it connects to the db,reads data from the db perfectly but doesnt write data.

I know its reading data perfectly cause it verify’s user credentials stored in db for login and displays user info, but it dosen’t perform any data insertion activity, upon that I dont get any error too, please help !

github –https://github.com/neelgeek/Paathshala-Management

Update –
I have somewhat figured out the problem, it seems there is some issue with mysqli statements used in the PHP files for Ajax calls in the project. I tested a test file with PDO statements and its working perfectly. Will update soon.

Advertisement

Answer

Solved
So after 3 hours of debugging each and every query, I found out the solution.

Reason 1 –
My version of MySQL didn’t allow me to keep columns with no default value unattended in a query. That means I had to specify each and every column in my query even if it was blank in a particular situation.
Solution – I had to go to each table and change the default value of each column which would be sometimes not specified in a query to some default value, mostly NULL worked for me.

Reason 2-
At some places I had not used <column-name> syntax, hence it was throwing an internal error, but as I was using phpmyadmin,I was not able to see the errors as phpmyadmin as no clear logging.
Solution-
Just make sure your SQL syntax is proper.

**Conclusion-**Finally I found that the main reason behind such errors is the SQL version, as each version has its own set of rules.

Thanks everyone who helped me in the comments 🙂

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement