You can call the mysql_real_query() function to execute an SQL statement that stmt_str points to.
Syntax
int
mysql_real_query(MYSQL *mysql,
const char *stmt_str,
unsigned long length)
Return values
0 is returned for an execution success, and a non-zero value is returned for errors.
Errors
CR_COMMANDS_OUT_OF_SYNC: Commands were executed in an improper order.
CR_SERVER_GONE_ERROR: The connection to the OBServer was disconnected.
CR_SERVER_LOST: The connection to the server was lost during the query.
CR_UNKNOWN_ERROR: An unknown error occurred.
Notes
Generally, a string must consist of a single SQL statement without a terminating semicolon (;) or \g. If multi-statement execution is enabled, a string can contain multiple statements separated with semicolons (;).
You cannot use the mysql_query() function to execute statements that contain binary data. Instead, you must use the mysql_real_query() function. (Binary data may contain the \0 character, which the mysql_query() function may parse as the end of a statement string.)
In addition, mysql_real_query() does not call strlen() on the statement string and therefore is faster than mysql_query().
Call the mysql_field_count() function to check whether the statement returns a result set.