If you don't know what you're doing, I would highly recommend against trying to "mass run" anything.
You also don't run anything from PHP. It's run from within mySQL itself. Before you do anything, make sure you have a full backup, etc.
From within mySQL, to generate a list of everything to convert:
SET @DATABASE_NAME = 'YOURDBNAME';
SELECT CONCAT('ALTER TABLE `', table_name, '` ENGINE=InnoDB;') AS sql_statements
FROM information_schema.tables AS tb
WHERE table_schema = @DATABASE_NAME
AND `ENGINE` = 'MyISAM'
AND `TABLE_TYPE` = 'BASE TABLE'
ORDER BY table_name DESC;
It will give you output like:
ALTER TABLE 'something' ENGINE=InnoDB;
ALTER TABLE 'blah' ENGINE=InnoDB;
ALTER TABLE 'another_name' ENGINE=InnoDB;
ALTER TABLE 'sometable' ENGINE=InnoDB;
Just copy/paste all of those ALTER TABLE lines in a single copy/paste.
Again... make sure you have a backup if you do this. I take no responsibility if you break your site or for unintended consequences, etc. (It is a relatively minor change, so it should be fine... but generally I don't suggest for people to play in the database unless they're very comfortable with what they're doing.