PDA

View Full Version : QMYSQL3: Unable to bind outvalues



sirguyon
9th May 2009, 02:56
XP Pro SP3
QT 4.5.1
MySQL 5.1.31
Using MinGW (NOT MS Visual Studio)

compiled MySQL plugin as described in
http://www.jiggerjuice.net/software/qt-sql-drivers.html

Everything works fine EXCEPT cannot get any query results. Always get...

Using unsupported buffer type: 3 (parameter: 3) QMYSQL3: Unable to bind outvalues

When I run the QT sqlbrowser demo it reports exactly the same problem. It does show the list of tables but any access to them, either by double-clicking on a table name or executing a query in the query window produces the above error.

This has been tried on TWO different machines, both of which are CLEAN (e.g. install and patch XP, install Apache 2.2.11, MySQL 5.1.31, PHP 5.2.8, QT 4.5.1, make plugins as per page above and copy qsqlmysqld4.dll, libqsqlmysqld4.a to c:\qt\plugins\sqldrivers)

I have searched and searched and have pretty much drawn a blank. Similar problems seem to have been fixed by changing mysql dll
e.g.
unsupported buffer type (http://groups.google.com/group/de.comp.datenbanken.mysql/browse_thread/thread/99656eab87b792d0/61d93704dae34c13)
mysql library problem (http://markmail.org/message/cvpqp7lp55islaau)
MySQL Strange behaviour (http://www.qtcentre.org/forum/f-qt-programming-2/t-qt45-mysql-strange-beheavior-19960.html/?highlight=mysql)

I have PCTools firewall installed. I have disabled this. No difference.
I have tried localhost and 127.0.0.1. No difference.
Using mysql command line client works perfectly.
Accessing database using PHP works perfectly


QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("localhost");
db.setDatabaseName(<valid database>);
db.setUserName(<valid username>);
db.setPassword(<valid password>);
bool ok = db.open();
if (ok)
{
// QSqlQuery query("select Event_Title from events where Event_ID=79");
QSqlQuery query("select event_title,s.series_id,series_title from events,series s where event_id=79 and events.series_id=s.series_id");
if (!query.isValid())
{
QMessageBox::information(this,"Last Error",query.lastError().text());
// The more simple query gives no error but also produces no results
// however QSqlError.errorNumber = -1
}

while( query.next() )
{
// NEVER EVER get here!!!!
// That is the problem in a nutshell!!!
QString event_title = query.value(0).toString();
QMessageBox::information(this,"event_title",event_title);
}
db.close();
}

I have tried just about every combination, property, and method of QSqlDatabase, QSqlQuery, QSqlQueryModel, QSqlRecord, QSqlError, etc... all to no avail.

The instance of the QSqlDatabase object seems to be connected ok. I can get a list of tables, etc. But that is all. And exactly the observed behaviour of the sqlbrowser demo as well.

I have tried a large number of SQL queries, and checked each query in phpMyAdmin (OK) and in the cmd line mysql client (OK).

I am a newbie to QT and think QT is awesome. But this is causing me some serious headache and heartache. Any suggestions or help gratefully received.

Thanks

sirguyon
9th May 2009, 11:13
Someone must be able to help. I accept that I've done something silly or missed an obvious step - I just can't believe that it would normally be so hard... all I want to do is talk to a MySQL database...

Could it be one of the many libmysql.dll files on my system? Is it doing something with the one in the PHP dir?

Is it something to do with my environment? My system path perhaps?

C:\Program Files\PHP\;%SystemRoot%\system32;%SystemRoot%;%Sys temRoot%\System32\Wbem;C:\Program Files\MySQL\MySQL Server 5.1\bin;C:\Program Files\TortoiseSVN\bin

I am so confused now about what is what and so much advice around the re-generation of the MySQL import library seems contradictory at best, and confusing at worst.

Am I making a mistake trying to use MinGW? Should I revert to VC6?

Please help.

sirguyon
9th May 2009, 11:59
OK, I took my own advice and started moving dlls around and changing paths...

I think the thing that did it was moving C:\Program Files\PHP\; to the end of the path.

%SystemRoot%\system32;%SystemRoot%;%Sys temRoot%\System32\Wbem;C:\Program Files\MySQL\MySQL Server 5.1\bin;C:\Program Files\TortoiseSVN\bin;C:\Program Files\PHP\;

If anyone can explain exactly why this matters (I assume that it has something to do with the libmysql.dll in the PHP directory) then I would really like to know.

I am not a makefile, compiler, or systems guru. I struggle enough writing little pieces of application code. But I still like to know WHY....

If something so simple was the problem then I can't believe that others haven't had similar issues.

Like I say, I'm not sure exactly what I've done to fix the problem and it leaves me feeling that things are a little fragile.

In this case a little knowledge would be a very welcome thing.

Thanks again

Lykurg
9th May 2009, 12:04
QSqlQuery query("select event_title,s.series_id,series_title from events,series s where event_id=79 and events.series_id=s.series_id");

Guess event_id is your primary key, so the result is only one row.
After executing query points to the first result.



while( query.next() )
{
// NEVER EVER get here!!!!

this is because there is no second row...

sirguyon
9th May 2009, 14:19
Lykurg said:

Guess event_id is your primary key, so the result is only one row.
After executing query points to the first result.

Sorry, don't think so. Yes, only one row is returned but this was just one out of many, many sql statements that were used while testing and experimenting.

From the QT Manual (QSqlQuery entry)

Successfully executed SQL statements set the query's state to active so that isActive() returns true. Otherwise the query's state is set to inactive. In either case, when executing a new SQL statement, the query is positioned on an invalid record. An active query must be navigated to a valid record (so that isValid() returns true) before values can be retrieved.

and


Navigating records is performed with the following functions:

* next()
* previous()
* first()
* last()
* seek()

So, even with just ONE record, using next is quite a good idea.

Anyway, great to get a response.

Does anyone else use MinGW & MySQL 5.1 with QT?

I suspect that if I hadn't had Apache & PHP installed I would have had no problem so far.

Lykurg
9th May 2009, 14:34
Sorry, don't think so.
Yes, yes, always gets puzzled that Qt does not.

But then your code is correct and works for me. So it has to do with your dll. What does QSqlDatabase::drivers() say?

sirguyon
9th May 2009, 14:52
The FIX was to move "c:\Program Files\PHP" to the END of the system path, after "MySQL\Bin"

The PHP dir had an older copy of libmysql.dll (installed by PHP)
(I suspect that this was the problem....)

I should know more but I don't. I'm embarrassed to ask... but what is the mechanism by which things link together? It all seems like magic to me...

And after using tools that I am not familiar with (reimp, dlltool, qmake, ming32-make) to create .a files (of which I only seem to have the debug(?) versions....) and moving things around... I am just a little confused... and I suspect a few other newbies could get into a similar situation... and have no idea how to get out of it.

To get into trouble... all you have to do is install PHP 5.2.8 and MySQL 5.1.31, and then install QT 4.5.1.

The answer is that.... you don't just have to have mysql\bin in the path... it has to be before the \php directory...

I would just like some confirmation that my analysis is correct. I would also like the next newbie who has such a problem to be able to find a relatively clear description\discussion of what the problem (and at least one possible solution) may be.

What do you think?

sirguyon
10th May 2009, 10:03
And it is never easy.... maybe my solution was wrong... because my PHP scripts now don't run... probably because they are now finding the wrong DLL....

I tried to find a PHP 5.2.8 / MySQL 5.1.31 version of php_mysqli.dll but couldn't find one.

In the end I downloaded the zip file of php-5.2.9-2-Win32.zip (http://www.php.net/get/php-5.2.9-2-Win32.zip/from/a/mirror)... and it still wouldn't work...

...so I replaced the downloaded php\ext files with PHP-5.2.9+_MySQL-5.1.30+.zip (http://www.apachelounge.com/download/mods/PHP-5.2.9+_MySQL-5.1.30+.zip) files....

And copied the libmysql.dll from the Mysql\Bin dir to the PHP dir...

...and then had to REBOOT.... and now everything works... and I suspect that the path order (see a previous post) would no longer matter...

Problem is, despite now having everything working, I am still not sure if I've just been chasing my tail.... did I miss the obvious and easy fix?

Raccoon29
19th November 2009, 10:23
Since we solved an analog problem, I want to put it here the thread as reference, maybe someone else is passing here through trying to find a solution for this frustrating problem.

This is the thread: http://www.qtcentre.org/forum/f-newbie-4/t-mysql-connects-but-doesnt-queries-it-queries-if-i-do-25725-post123213.html#post123213

HTH