1
#include <iostream>
#include<mysql.h>

using namespace std;

int main()
{
    MYSQL* conn;
    conn = mysql_init(0);
    conn = mysql_real_connect(conn,"sql12.freemysqlhosting.net","sql123893..","nYES4ifTZ1","sql123893..", 0, NULL, 0);
    if(conn){
        cout<<"Connected";
    }
    else{
        cout<<"Not Connected";
    }
    return 0;
}

I am trying to connect live database in my cpp application But it not connecting please anyone give example to connect live database in cpp in codeblocks

Ulrich Eckhardt
  • 16,572
  • 3
  • 28
  • 55
Harsh Kairamkonda
  • 387
  • 1
  • 6
  • 18
  • Maybe your account information is incorrect. Does it connect in MySQL workbench with the same account info? – drescherjm Jan 30 '21 at 15:31
  • Please tell us what you saw, not just your interpretation. Also, read the functions' documentation to find out about how they signal errors and how to distinguish different error types. – Ulrich Eckhardt Jan 30 '21 at 15:32
  • @drescherjm yes its connected i have checked in http://www.phpmyadmin.co/ this site – Harsh Kairamkonda Jan 30 '21 at 15:35

0 Answers0