The problem is that SQL needs to explicitly be told what database you're using, either on a global level or on each individual table create query. There's two things we need to do here:
A) If that database doesn't exist, you'll need to create it first. There's no way to put something in a database that isn't there.
B) Make sure you tell the query which database to use. The solution you linked uses this solution. You'll only want to use it if all the tables are going to one database. The line is:
USE `database_name`;
replacing database_name
with the name of the database that you're going to use.
However, if each table belongs to a different database, you'll want to change the following:
CREATE TABLE IF NOT EXISTS `attend` (
to
CREATE TABLE IF NOT EXISTS `database_name`.`attend` (
replacing database_name
with the name of the database that table is going to be a part of.