We will start by invoking the mysql_init function to initialize a MYSQL object by the name conn. Thereafter, we will invoke the mysql_real_connect function and pass the MYSQL object conn to it along with the valid user ID, password, and the host details. The mysql_real_connect function will establish a connection to the MySQL server running at the specified host and will also connect to the supplied database, ecommerce. The MYSQL object conn will act as the connection handler for the rest of the program. Wherever a connection to the MySQL server and ecommerce database is required, referring to conn will suffice.
If any error occurs in establishing a connection to the MySQL database engine or the ecommerce database, an error ...