Hi, Im trying to connect to a database but it doesn't seem to work. This is the code I'm using:
#include "stdafx.h"
#include <iostream>
#include <my_global.h>
#include <mysql.h>
using namespace std;
int main(int argc, char **argv)
{
MYSQL *conn;
conn = mysql_init(NULL);
if (conn == NULL) {
printf("Error %u: %s\n", mysql_errno(conn), mysql_error(conn));
}
if (mysql_real_connect(conn, "mysql9.000webhost.com", "user", "password", "database", 0, NULL, 0) == NULL) {
printf("Error %u: %s\n", mysql_errno(conn), mysql_error(conn));
}
if (mysql_query(conn, "INSERT INTO shoutbox (message, author, eml, date, ip) VALUES ('heya','me','sy@so.com','07:07 AM 27th May','141.85.0.113')")) {
printf("Error %u: %s\n", mysql_errno(conn), mysql_error(conn));
}
mysql_close(conn);
}
It says: Can't connect to mysql server on mysql9.000webhost.com. The database does work and I've checked all the information a dozen times, it should work, but it doesn't.