For PHP, if you want to install a different version from what is what is available in the distribution's official repository, you can use the compile from source install method instead of package (default).
Simply change default['php']['install_method']
to 'source'
and run the default recipe. Alternatively explicitly run php::source ;-)
NOTE: You also need to change the default['php']['url'], default['php']['version'], default['php']['checksum'], etc to suite your needs.
For MySQL, as Mark said, it is up to the distribution (the version from its repository), looking at the mysql::server there isn't easy way to change it, as there is no such option as PHP (install by compiling from source) like the PHP cookbook.