g++ and mySQL]
Hello friends, I am trying to connect mySQL thru g++. I could connect the db and execute a query. But I want to get a value from key board and pass the same inside the query. ie, This is the query I am passing. mysql_query(connection,insert into table-name values ('1','aaa','bbb','ccc')); But I want to read the values for aaa, bbb, ccc and pass into the query. How can I do it. I am a just a beginner in C/C++ Regards -- .''`. Dileep M. Kumar [EMAIL PROTECTED] : :' :http://www.kumarayil.net `. `'` `- Debian GNU/Linux - Choice of the Freedom Lovers - 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
Re: g++ and mySQL]
Hi, If i understand well you wish to concatenate different strings. Are many options but the most handy solution is if you use sprintf. Regards, Gelu _ G.NET SOFTWARE COMPANY Permanent e-mail address : [EMAIL PROTECTED] [EMAIL PROTECTED] - Original Message - From: Dileep M. Kumar [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, January 16, 2003 1:10 PM Subject: g++ and mySQL] Hello friends, I am trying to connect mySQL thru g++. I could connect the db and execute a query. But I want to get a value from key board and pass the same inside the query. ie, This is the query I am passing. mysql_query(connection,insert into table-name values ('1','aaa','bbb','ccc')); But I want to read the values for aaa, bbb, ccc and pass into the query. How can I do it. I am a just a beginner in C/C++ Regards -- .''`. Dileep M. Kumar [EMAIL PROTECTED] : :' :http://www.kumarayil.net `. `'` `- Debian GNU/Linux - Choice of the Freedom Lovers - 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 - 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
Re: g++ and mySQL]
Hi. On Thu 2003-01-16 at 13:54:14 +0200, [EMAIL PROTECTED] wrote: Hi, If i understand well you wish to concatenate different strings. Are many options but the most handy solution is if you use sprintf. Well, in C++ you would rather use stringstream, because it has better type and bounds checking. Something like (untested): #include sstream [...] std::ostringstream query; query insert into table-name values (1, ' my_escape(aaa) ', ' my_escape(bbb) ', ' my_escape(ccc) ') mysql_query( connection, query.str().c_str() ); (where my_escape is some function calling mysql_real_escape_string()) Or alternatively, use the mysqlcpp, the C++-API (which I am not so fond of). HTH, Benjamin. [...] I am trying to connect mySQL thru g++. I could connect the db and execute a query. But I want to get a value from key board and pass the same inside the query. ie, This is the query I am passing. mysql_query(connection,insert into table-name values ('1','aaa','bbb','ccc')); But I want to read the values for aaa, bbb, ccc and pass into the query. How can I do it. I am a just a beginner in C/C++ -- [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
Re: g++ and mySQL]
Hi Benjamin, - Original Message - From: Benjamin Pflugmann [EMAIL PROTECTED] To: Gelu Gogancea [EMAIL PROTECTED] Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Thursday, January 16, 2003 4:23 PM Subject: Re: g++ and mySQL] Hi. On Thu 2003-01-16 at 13:54:14 +0200, [EMAIL PROTECTED] wrote: Hi, If i understand well you wish to concatenate different strings. Are many options but the most handy solution is if you use sprintf. Well, in C++ you would rather use stringstream, because it has better type and bounds checking. Something like (untested): An object type which is C-style(c_str()) and which is null terminated array of characters. In this case i wonder ...if is a better bounds checking or is a little wasted of memory ?...considering that we never know from the begining the size of the string.In fact, i think that is the main purpose of the string type.This is indeed a facility for the programmer. #include sstream [...] std::ostringstream query; query insert into table-name values (1, ' my_escape(aaa) ', ' my_escape(bbb) ', ' my_escape(ccc) ') mysql_query( connection, query.str().c_str() ); (where my_escape is some function calling mysql_real_escape_string()) Or alternatively, use the mysqlcpp, the C++-API (which I am not so fond of). ...on this point we can handshake. HTH, Benjamin. Best regards, Gelu [...] I am trying to connect mySQL thru g++. I could connect the db and execute a query. But I want to get a value from key board and pass the same inside the query. ie, This is the query I am passing. mysql_query(connection,insert into table-name values ('1','aaa','bbb','ccc')); But I want to read the values for aaa, bbb, ccc and pass into the query. How can I do it. I am a just a beginner in C/C++ -- [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 - 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
Re: g++ and mySQL
On Thu, Jan 16, 2003 at 01:54:14PM +0200, Gelu Gogancea wrote: If i understand well you wish to concatenate different strings. Are many options but the most handy solution is if you use sprintf. Thanks I got the answer. sprintf(QueryStr,INSERT INTO %s VALUES ('%s', '%s', '%s', '%s'), table-name, value1, value2, value3, value4); Regards -- .''`. Dileep M. Kumar [EMAIL PROTECTED] : :' :http://www.kumarayil.net `. `'` `- Debian GNU/Linux - Choice of the Freedom Lovers - 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
segmentation fault with g++/cygwin/mysql
Hi all, I hava a little problem for developping a windows mysql client program in C++. I compile it using cygwin. there is no problem during the compilation but when I execute it, it seems that when I execute a select query and retrieve the data, it access memory that it shouldn't. I tested my program under linux and no problem. So, if somebody have an explication... I use Win 98 and cygwin 1.1.8 - 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