title: Qt MySQL Query - Unable to bind value
body: <p>I finally fixed my MySQL connection in C++ Qt. However, when I try to bind values, I get the following error:</p>
  
  <pre><code>QSqlError("2036", "QMYSQL3: Unable to bind value", "Using unsupported buffer type: 1701052421  (parameter: 1)")
  </code></pre>
  
  <p>I have these files:</p>
  
  <p>Engine.h:</p>
  
  <pre><code>#ifndef ENGINE_H
  #define ENGINE_H
  
  #include "database/mysql.h"
  
  class engine
  {
  private:
      static mysql* _mysql;
  public:
      static void initialize();
      static void destroy();
  
      static mysql get_mysql();
  };
  
  #endif // ENGINE_H
  </code></pre>
  
  <p>Engine.cpp:</p>
  
  <pre><code>#include "engine.h"
  #include "entities/member_controller.h"
  #include &lt;QDebug&gt;
  
  mysql* engine::_mysql;
  
  void engine::initialize()
  {
      _mysql = new mysql();
  
      member* mem = member_controller::get_member(1);
      qDebug() &lt;&lt; "mem name = " &lt;&lt; mem-&gt;getFirstName() &lt;&lt; " " &lt;&lt; mem-&gt;getSecondName();
      delete mem;
  }
  
  void engine::destroy()
  {
      delete _mysql;
  }
  
  mysql engine::get_mysql()
  {
      return *_mysql;
  }
  </code></pre>
  
  <p>mysql.h:</p>
  
  <pre><code>#ifndef MYSQL_H
  #define MYSQL_H
  
  #include &lt;QtSql&gt;
  #include &lt;QString&gt;
  #include "mysql_result.h"
  
  class mysql
  {
  private:
      QSqlDatabase db;
  public:
      mysql();
      ~mysql();
      mysql_result create_result(QString query);
      QSqlError error();
  
      QSqlQuery query_prepare(QString query1)
      {
          QSqlQuery query(this-&gt;db);
          query.prepare(query1);
  //        this-&gt;query = query;
          return query;
      }
  };
  
  #endif // MYSQL_H
  </code></pre>
  
  <p>(query_prepare body temp. in header file just to test)</p>
  
  <p>mysql.cpp</p>
  
  <pre><code>#include "mysql.h"
  
  mysql::mysql()
  {
      this-&gt;db = QSqlDatabase::addDatabase("QMYSQL", "QMYSQL");
      this-&gt;db.setHostName("localhost");
      this-&gt;db.setUserName("root");
      this-&gt;db.setPassword("Eequi4");
      this-&gt;db.setDatabaseName("test");
      this-&gt;db.open();
  }
  
  mysql::~mysql()
  {
  }
  
  QSqlError mysql::error()
  {
      return this-&gt;db.lastError();
  }
  </code></pre>
  
  <p>member_controller.h:</p>
  
  <pre><code>#ifndef MEMBER_CONTROLLER_H
  #define MEMBER_CONTROLLER_H
  
  #include &lt;QString&gt;
  #include "member.h"
  
  class member_controller
  {
  public:
     static member* get_member(unsigned int id);
     static member* get_member(QString email);
  };
  
  #endif // MEMBER_CONTROLLER_H
  </code></pre>
  
  <p>member_controller.cpp:</p>
  
  <pre><code>#include "member_controller.h"
  #include "database/mysql_result.h"
  
  #include "engine.h"
  #include "database/mysql_result.h"
  #include &lt;QtSql/QSqlQuery&gt;
  
  member* member_controller::get_member(unsigned int id)
  {
      QSqlQuery result = engine::get_mysql().query_prepare("SELECT * FROM members WHERE member_id = :mem_id");
      result.bindValue(":mem_id", id);
  
      if (result.exec() &amp;&amp; result.first())
      {
          return new member(id, result.value("first_name").toString(), result.value("second_name").toString(), result.value("screen_name").toString(), result.value("email").toString(), result.value("status").toString());
      }
      else
      {
          qDebug() &lt;&lt; engine::get_mysql().error() &lt;&lt; "\n";
          qDebug() &lt;&lt; result.lastError() &lt;&lt; "\n";
      }
  
      return new member(0, "", "", "", "", "");
  }
  </code></pre>
  
  <p>I hope this is all the code needed. I tried using questionmark except of :mem_id but no luck either.</p>