[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Why am I getting a segmentation fault?



I'm wondering why I am getting a segmentation fault when selecting the db.
I connect fine to the server. Any help would be great,

==========================

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


MYSQL *mysql;
MYSQL_RES *res;
MYSQL_ROW row;

#define myDb "menagerie"


int main()
{


  if (!mysql_connect(mysql,"host","username","password")){
    cout << "Error connecting" << endl;
    return 1;
  }

  // this is where the fault is happening.
  if (mysql_select_db(mysql, myDb)){
    cout << "Error getting DB" << endl;
    return 1;
  }

  mysql_close(mysql);

  cout << "Wow it worked!" << endl;
  return 0;

}
=========================================

Tom


Reply to: