Instead of using only mysql_query() you can use sprintf() and mysql_query() like this.
sprintf(strquery, "INSERT INTO pending(mbmid, pw_name,pw_domain) VALUES('%s', '%s', '%s')", mbmID, Uname, Udomain); mysql_query(my_connection, strquery); -----Original Message----- From: rm [mailto:[EMAIL PROTECTED]] Sent: Wednesday, June 19, 2002 10:38 AM To: [EMAIL PROTECTED] Subject: INSERT using C API Hello list, I'm new to C programming, and have used MySQL for only a short time; but I've got a situation where I need to update an existing table using a C function. I'm working on Redhat 7.1 using the MySQL rpm that came with the package. I've written the function so that it compiles, and executes from the command line, and updates the MySQL table - but only with the static entries I write into the code. This is the INSERT statement: res = mysql_query(my_connection, "INSERT INTO pending(mbmid, pw_name, pw_domain) VALUES('9999', 'anyname', 'anydomain')"); Using the above INSERT statement the values are correctly added to the table. But, what I'm trying to do is find the correct method to use variables in lieu of the constants. I've tried: res = mysql_query(my_connection, "INSERT INTO pending(mbmid, pw_name, pw_domain) VALUES('%s', '%s', '%s')",mbmID, Uname, Udomain); but I get a compile error saying "too many arguments for function my_connection" I'd guess I'm making a simple mistake here, but I've not been able to find any documentation on this, and the C boards seem to think it's a question more suited for a MySQL list. Any suggestions or insights would be greatly appreciated. thanks, rm --------------------------------------------------------------------- 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