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

Reply via email to