Please help me with the following c code:

                sprintf(update, "update chrc set center='");
                len = 24;
                memcpy(update+len, center, 128);
                len += 128;
                sprintf(update+len, "', var='");
                len += 8;
                memcpy(update+len, var, 128);
                len += 128;
                sprintf(update+len, "' where cc='%s'", row[0]);
                len += 15;

                if (ret = mysql_real_query(conn, update, len))
                        printf("fail update %d\n", ret);

int center[4][8], var[4][8]
row[0] is a chinese character (2 bytes)
update is a buffer of char [500]

mysql> describe chrc;
+--------+------------------+------+-----+---------+-------+
| Field  | Type             | Null | Key | Default | Extra |
+--------+------------------+------+-----+---------+-------+
| cc     | char(2) binary   | YES  |     | NULL    |       |
| count  | int(11)          | YES  |     | NULL    |       |
| center | char(128) binary | YES  |     | NULL    |       |
| var    | char(128) binary | YES  |     | NULL    |       |
+--------+------------------+------+-----+---------+-------+

The query I want to do is
"update chrc set center='--', var'++' where cc='xx'" (1)
where -- is center[4][8] (all of them), ++ is var[4][8], and xx is the chinese 
character.

The result I get is that all rows in the table chrc are updated. And it can be seen 
from /var/log/mysql/mysql.log, the query executed is
"update chrc set center='" (2)
But I dumped the variable update to a file, and it is exactly as what I want in (1).

Please point me out what is the problem.
Thank you very much.

---------------------------------------------------------------------
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