At 01:49 2001-09-05 -0700, George Greer wrote: >On Wed, 5 Sep 2001, Artovil wrote: > 23.4.42.2 Example > >char query[1000],*end; > >end = strmov(query,"INSERT INTO test_table values("); >*end++ = '\''; >end += mysql_real_escape_string(&mysql, end,"What's this",11); >*end++ = '\''; >*end++ = ','; >*end++ = '\''; >end += mysql_real_escape_string(&mysql, end,"binary data: \0\r\n",16); >*end++ = '\''; >*end++ = ')'; > >if (mysql_real_query(&mysql,query,(unsigned int) (end - query))) >{ > fprintf(stderr, "Failed to insert row, Error: %s\n", > mysql_error(&mysql)); >} > > The strmov() function used in the example is included in the >mysqlclient library and works like strcpy() but returns a > pointer to the terminating null of the first parameter. >----- > >You should use that function instead of trying to write your own. You'll >need '-lmysqlclient' to LIBS= in Makefile if you're not already using it. I already have everything set up in the Makefile. Well, I thought about mysql_real_escape_string() as well before I emailed, but to structure a query that has 68 columns in that manner would take a bzillion lines of code. Are you sure that this is the only way to do it? I can't use the sprintf? It just seems very painful. Very very painful. Which is best, to do the 68 column query with mysql_real_escape_string() and have about 136 *end++='\'' and 67 *end++=',' in there, or to use 68 temporary chars and just use sprintf() to put it all together? What does these two options do with performance and memory and all of that? What if I had to loop something over, like player affects, and concatenated insert strings together, and then ran that query? Which option would be best then? And why is it so hard to use some kind of function inside a sprintf that strips the ' and replaces them with \' instead? The one I had was obviously wrong, but you never said what was wrong with it or why, you just said it was due to lack of understanding static. That answer would make sense if I actually DID understand static, but since I don't, you know where this is all going... I appologize for all my short-comings, and I hope that you can offer some advice and help. Kind regards, /Artovil -- +---------------------------------------------------------------+ | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html | | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html | +---------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/06/01 PST