Problem with Query statement
Feb 9, 2010 at 1:11pm UTC
Hey guys
I want to insert values into a MySql database. The following line works fine:
1 2 3
mysql_query(connection, "INSERT INTO main (NumofShows , Title) VALUES('12', 'Home')" );
but if the data to be inserted is from a string... like....
1 2
string NewTitle = "Monaco" ;
string NumofShows = "2" ;
How do i edit my sql statements so variables can be inserted into the Values ( ) , and it will be able to read the variables and then store it into the database.
Feb 9, 2010 at 2:22pm UTC
you need to create string that has the same key words as in your example,
and then call
mysql_query(connection, myQuery.c_str());
where
myQuery it's your created string
Feb 9, 2010 at 2:49pm UTC
What do u mean by same keyword? could you show me how is it done based on the example i gave?
Feb 9, 2010 at 3:03pm UTC
Feb 9, 2010 at 4:56pm UTC
I am not very clear about it. Could you show me how is it done on my example?
Topic archived. No new replies allowed.