So this problem is apparently related to the mysql server version. This php function:
mysql_query("INSERT INTO `x_servers_pay`(`service_type`, `ip`, `time_created`, `amount`, `currency`,`receiver_email`) VALUES ('boost','".mysql_real_escape_string($ip)."','".time()."','".$price_boost."','".$currency_boost."','".$receiver_email."')");
works perfectly on mysql 5.5.49 and 5.5.41 but doesn't seem to work with mysql server 5.7. There is another simplier function which is also INSERT which works but that particular one does not and I completely ran out of ideas why.
I couldn't find any error logs in php-fpm log folder or nginx log folder.
Can anyone make a suggestion?