John Dean wrote:

> Hi
> I think you should check the API documentation

Can you point me to some docs about this?

> because you code example is
> wrong. Each connection should have its own initialized connection handle.
> You have only initialized one data structure i.e. mysql, which is passed
> three times to mysql_real_connect, so of course conn1 == conn2.

You are saying that the good code is:

mysql_init(&mysql1)
conn1 = mysql_real_connect(&mysq1, ip1, user1, pass1, db1, 0, NULL, 0)

mysql_init(&mysql2)
conn12= mysql_real_connect(&mysq2, ip2, user2, pass2, db2, 0, NULL, 0)

...?

> And why are
> passing a reference to the MYSQL data structure and not a pointer?

What do you mean, the typecast ((Ptr)&mysql)?

>
>
> At 14:31 12/01/2001 +0100, you wrote:
> >Hi,
> >I'm building a MySQL C API client. I need to connect to different dbs
> >at the same time. My code is (approximately):
> >
> >//============================
> >MYSQL mysql, *conn1, *conn2;
> >
> >mysql_init(&mysql)
> >
> >  conn1 = mysql_real_connect(&mysq, ip1, user1, pass1, db1, 0, NULL, 0)
> >  printf("conn1 = %d", conn1);
> >
> >  conn2 = mysql_real_connect(&mysq, ip2, user2, pass2, db2, 0, NULL, 0)
> >  printf("conn2 = %d", conn1);
> >
> >  conn3 = mysql_real_connect(&mysq, ip3, user3, pass3, db3, 0, NULL, 0)
> >  printf("conn3 = %d", conn3);
> >
> >  // ... use conn1
> >  // ... use conn2
> >  // ... use conn3
> >
> >  mysql_close(conn1);
> >  mysql_close(conn2);
> >  mysql_close(conn3);
> >
> >mysql_close(&mysql);
> >//============================
> >
> >I see always that (conn1 == conn2), so the first connection is lost.
> >Could you give some explanation about this?
> >How can I mantain different connections on different db (ip, user,
> >etc....)?
> >
> >
> >
> >==================================================================
> >Valerio Ferrucci                        Tabasoft Sas
> >[EMAIL PROTECTED]                      http://tabasoft.ancitel.it
> >                                         [EMAIL PROTECTED]
> >
> >
> >
> >---------------------------------------------------------------------
> >Before posting, please check:
> >    http://www.mysql.com/manual.php   (the manual)
> >    http://lists.mysql.com/           (the list archive)
> >
> >To request this thread, e-mail <[EMAIL PROTECTED]>
> >To unsubscribe, e-mail <[EMAIL PROTECTED]>
> >Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>
> Regards
> John
>
> MySQL Development Team
>     __  ___     ____ __   __
>    /  |/  /_ __/ __/ __ \/ /   John Dean <[EMAIL PROTECTED]>
>   / /|_/ / // /\ \/ /_/ / /__  MySQL AB, http://www.mysql.com/
> /_/  /_/\_, /___/\___\_\____/ Mansfield, England, UK
>         <___/

--

==================================================================
Valerio Ferrucci                        Tabasoft Sas
[EMAIL PROTECTED]                      http://tabasoft.ancitel.it
                                        [EMAIL PROTECTED]



---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to