SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 13/06/2018, 01:15 PM   #1
CaptainBoi
Big Clucker
 
Join Date: May 2018
Location: India
Posts: 101
Reputation: 7
Default MySQL help

i am just new in mysql but i got it better alot in making systems etc etc
but i want to know that how can i make it based for 2 hosts like
if defined server_host
#define MYSQL_HOST ""
#define MYSQL_USER ""
#define MYSQL_PASS ""
#define MYSQL_DB ""

load this information but if Localhost defined then use the other one

like i tried by this
PHP Code:
#define LOCAL_HOST
#define SERVER_HOST

#if defined SERVER_HOST
/* Mysql Entities */
#define MYSQL_HOST    ""
#define MYSQL_USER    ""
#define MYSQL_PASS     ""
#define MYSQL_DB    ""
/* Mysql Entities */
#endif

#if defined LOCAL_HOST
/* Local Host */
#define MYSQL_HOST    ""
#define MYSQL_USER    ""
#define MYSQL_PASS     ""
#define MYSQL_DB    ""
/* Local Host */
#endif 
help please i want it so i dont have to define that again and again and it work in both
localhost and server host
CaptainBoi is offline   Reply With Quote
Old 13/06/2018, 01:50 PM   #2
Slawi
Big Clucker
 
Join Date: Dec 2013
Posts: 50
Reputation: 1
Default Re: MySQL help

PHP Code:
//#define LOCAL_HOST
#define SERVER_HOST

#if defined SERVER_HOST
/* Mysql Entities */
#define MYSQL_HOST    ""
#define MYSQL_USER    ""
#define MYSQL_PASS     ""
#define MYSQL_DB    ""
/* Mysql Entities */
#else
/* Local Host */
#define MYSQL_HOST    ""
#define MYSQL_USER    ""
#define MYSQL_PASS     ""
#define MYSQL_DB    ""
/* Local Host */
#endif


public OnGameModeInit()
{

    
#if defined SERVER_HOST
    
g_SQL mysql_connect(MYSQL_HOSTMYSQL_USERMYSQL_PASSMYSQL_DB);
    
#else
     
g_SQL mysql_connect(MYSQL_HOSTMYSQL_USERMYSQL_PASSMYSQL_DB);
     
#endif


and check wiki for more information about MySQL
Code:
http://wiki.sa-mp.com/wiki/MySQL/R40
Slawi is offline   Reply With Quote
Old 13/06/2018, 03:01 PM   #3
CaptainBoi
Big Clucker
 
Join Date: May 2018
Location: India
Posts: 101
Reputation: 7
Default Re: MySQL help

thanks alot
CaptainBoi is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
MySQL Plugin r39-2 Error: Can't connect to local MySQL server through socket Emre__ Scripting Help 10 30/07/2014 08:26 AM
[Tutorial] [VIDEO] MySQL ORM r38: How to pair GM with MySQL & creation of registration/connection system cArnasLT Tutorials 3 19/05/2014 02:08 PM
BlueG MySQL plugin - Failed (plugins/mysql.so: undefined symbol: _Z13stringvprintfPKcPc) linuxthefish Plugin Development 10 13/07/2013 10:56 AM
[Tool/Web/Other] MySQL DB Manager - Easily manage your MySQL databases with this remote application fiki574 Tools and Files 13 22/07/2012 09:41 AM


All times are GMT. The time now is 08:15 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.