C API Function Descriptions
2178
•
CR_IPSOCK_ERROR
[2942]
Failed to create an IP socket.
•
CR_OUT_OF_MEMORY
[2942]
Out of memory.
•
CR_SOCKET_CREATE_ERROR
[2941]
Failed to create a Unix socket.
•
CR_UNKNOWN_HOST
[2942]
Failed to find the IP address for the host name.
•
CR_VERSION_ERROR
[2942]
A protocol mismatch resulted from attempting to connect to a server with a client library that uses a
different protocol version.
•
CR_NAMEDPIPEOPEN_ERROR
[2942]
Failed to create a named pipe on Windows.
•
CR_NAMEDPIPEWAIT_ERROR
[2942]
Failed to wait for a named pipe on Windows.
•
CR_NAMEDPIPESETSTATE_ERROR
[2943]
Failed to get a pipe handler on Windows.
•
CR_SERVER_LOST
[2942]
If
connect_timeout
[445]
> 0 and it took longer than
connect_timeout
[445]
seconds to
connect to the server or if the server died while executing the
init-command
.
Example
MYSQL mysql;
mysql_init(&mysql);
mysql_options(&mysql,MYSQL_READ_DEFAULT_GROUP,"your_prog_name");
if (!mysql_real_connect(&mysql,"host","user","passwd","database",0,NULL,0))
{
fprintf(stderr, "Failed to connect to database: Error: %s\n",
mysql_error(&mysql));
}
By using
mysql_options()
the MySQL library reads the
[client]
and
[your_prog_name]
sections in the
my.cnf
file which ensures that your program works, even if someone has set up
MySQL in some nonstandard way.
Note that upon connection,
mysql_real_connect()
sets the
reconnect
flag (part of the
MYSQL
structure) to a value of
1
in versions of the API older than 5.0.3, or
0
in newer versions.
A value of
1
for this flag indicates that if a statement cannot be performed because of a lost
connection, to try reconnecting to the server before giving up. As of MySQL 5.0.13, you can use the
MYSQL_OPT_RECONNECT
option to
mysql_options()
to control reconnection behavior.
20.6.6.53.
mysql_real_escape_string()
unsigned long mysql_real_escape_string(MYSQL *mysql, char *to, const char
*from, unsigned long length)
Summary of Contents for 5.0
Page 1: ...MySQL 5 0 Reference Manual ...
Page 18: ...xviii ...
Page 60: ...40 ...
Page 396: ...376 ...
Page 578: ...558 ...
Page 636: ...616 ...
Page 844: ...824 ...
Page 1234: ...1214 ...
Page 1427: ...MySQL Proxy Scripting 1407 ...
Page 1734: ...1714 ...
Page 1752: ...1732 ...
Page 1783: ...Configuring Connector ODBC 1763 ...
Page 1793: ...Connector ODBC Examples 1773 ...
Page 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Page 2850: ...2830 ...
Page 2854: ...2834 ...
Page 2928: ...2908 ...
Page 3000: ...2980 ...
Page 3122: ...3102 ...
Page 3126: ...3106 ...
Page 3174: ...3154 ...
Page 3232: ...3212 ...