makamum,
phpMyAdmin (in SME) uses the mysql root user/password and so can mask problems with ordinary users. Because you sppecify you can run mysql queries in php code, and get valid results, I have to assume you have established the permissions for a user and related the user and permissions to a particular server/IP.
In the permissions forms in phpMyAdmin, you want to be sure not to give regular users any "global" permissions, but instead pick the database(s) you want to give the user access to, and then to write in the data base be sure they have insert and update permissions under the Data section.
If you still can't write to the database, you will need to capture the mysql error provided as a result of the query and either look it up or post it here for someone to help with.