You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Connects to a database, returns handle to database connection. If you want to connect to multiple databases, you can call this function up to 4 times. Do not forget to close connection with `mysql_close()`. TODO: link here!
19
15
20
-
#### `mysql_real_connect()`
16
+
If "localhost" passed as `host`, for *NIX OS will be changed to "127.0.0.1".
21
17
22
-
Connects to a database
18
+
Usage example 1: `handle = mysql_real_connect("localhost", "cod4server", "12345678", "players");`
23
19
24
-
Usage example `db = mysql_real_connect(host, user, pass, db, *port)`
20
+
Usage example 2: `handle = mysql_real_connect("255.125.255.125", "usr1337", "87654321", "stats", 1337);`
25
21
26
-
####### Note: *the port pram is optional
27
22
28
-
###### Use 127.0.0.1 on unix, and the default port for mysql is 3306.
23
+
####`mysql_close(<handle>)`
29
24
30
-
#### `mysql_close()`
25
+
Close a MySQL connection. Handle must be valid.
31
26
32
-
Close a MySQL Connection
27
+
Usage example: `mysql_close(handle);`
33
28
34
-
Usage example `mysql_close()`
29
+
#### `mysql_query(<handle>, <str query>)`
35
30
36
-
#### `mysql_errno()`
31
+
Send a query to a database and saves the result for use in following functions. Must be called after `mysql_real_connect()`.
37
32
38
-
Returns the MySQL Error number.
39
-
Usage example: `error = mysql_errno()`
33
+
Usage example: `mysql_query(handle, "SELECT * from users");`
40
34
41
-
#### `mysql_error()`
35
+
#### `mysql_num_rows(<handle>)`
42
36
43
-
Returns the MySQL Error number.
44
-
Usage example: `error = mysql_error()`
37
+
Returns the amount of rows received after latest query. Must be called after `mysql_real_connect()` and `mysql_query()`.
Returns next row from latest query result as array. Array's keys are equal to column names and can be found with `getArrayKeys(<array>)`. An empty array returned if there's no more rows left. Must be called after `mysql_real_connect()` and `mysql_query()`.
Returns all rows from latest query result as 2-dimensional array. Array's keys are equal to column names and can be found with `getArrayKeys(<array>)`. An empty array returned if there's no more rows left. Must be called after `mysql_real_connect()` and `mysql_query()`.
0 commit comments