Scripting/Squirrel/Functions/mysql connect: Difference between revisions

From Vice City Multiplayer
Jump to navigation Jump to search
Caution icon
This wiki is using an old backup from 2020
Some information may be old/missing
No edit summary
m (Add argument type declaration and cleanup the example.)
 
Line 2: Line 2:


== Syntax ==
== Syntax ==
 
<source lang=squirrel>
<pre>mysql_connect( host, dbuser, dbpassword, dbname);</pre>
mysql_connect( host, dbuser, dbpassword, dbname);
</source>


== Arguments ==
== Arguments ==
 
* ''string'' '''host''' - The host of the MySQL database (Most cases "localhost")
* '''host''' - The host of the MySQL database (Most cases "localhost")
* ''string'' '''dbuser''' - The MySQL user name.
* '''dbuser''' - The MySQL user name.
* ''string'' '''dbpassword''' - The MySQL user password.
* '''dbpassword''' - The MySQL user password.
* ''string'' '''dbname''' - The MySQL database name.
* '''dbname''' - The MySQL database name.


== Example ==
== Example ==
 
<source lang=squirrel>
<source lang=squirrel>function onScriptLoad()
function onScriptLoad() {
{
  db <- mysql_connect( "localhost", "vcmp", "test123", "vcmpdb");
db <- mysql_connect( "localhost", "vcmp", "test123", "vcmpdb");
}
}</source>
</source>
 


=== Notes ===
=== Notes ===
You can also remotely connect to a MySQL database, replace "localhost" with the remote host IP and make sure the host accepts remote connections.
You can also remotely connect to a MySQL database, replace "localhost" with the remote host IP and make sure the host accepts remote connections.



Latest revision as of 10:30, 26 April 2019

This function will connect to a MySQL database on the server.

Syntax

mysql_connect( host, dbuser, dbpassword, dbname);

Arguments

  • string host - The host of the MySQL database (Most cases "localhost")
  • string dbuser - The MySQL user name.
  • string dbpassword - The MySQL user password.
  • string dbname - The MySQL database name.

Example

function onScriptLoad() {
  db <- mysql_connect( "localhost", "vcmp", "test123", "vcmpdb");
}

Notes

You can also remotely connect to a MySQL database, replace "localhost" with the remote host IP and make sure the host accepts remote connections.

Related Functions