Jump to content

Errors


Recommended Posts

Hello all i'm today i'm started with lua and i have problem with mysql "defines"

If where are macro function #define ? Because i have error unexpected symbol near "#"

my stuff:

#define MySQL_HOST "localhost" 
#define MySQL_USER "root" 
#define MySQL_PASS "" 
#define MySQL_DATA "fr" 
  
  
mysql = mysql_connect(MySQL_HOST, MySQL_USER, MySQL_PASS, MySQL_DATA) 
  
if (not mysql) then 
    outputDebugString("Unable to connect to the MySQL server") 
    mysql_close(mysql) 
else 
    outputDebugString("Connected") 
end 

Ohh at this moment i'm confused because i think where are somethink like #define

Link to comment

There is no way to define a constant in LUA like you can in C. It's really not necessary. In your case, just do:

  
MySQL_HOST =  "localhost" 
MySQL_USER =  "root" 
MySQL_PASS = "" 
MySQL_DATA = 
  

If you want them to be global to all server or client side scripts in this resource. Since this is MySQL stuff though, your probably only going to need it in this script, so:

  
local MySQL_HOST =  "localhost" 
local MySQL_USER =  "root" 
local MySQL_PASS = "" 
local MySQL_DATA = 
  

would be a better solution.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...