MYSQL error help
#1

Hello I started writing a new game mode and when I add following lines to my game mode, it game me error while compilation. I tried reading wiki if I can get some mistake but didn't got any. probably some logical mistake?

Код:
S:\SAMP Stuff\gamemodes\new.pwn(229) : error 029: invalid expression, assumed zero
S:\SAMP Stuff\gamemodes\new.pwn(229) : warning 217: loose indentation
S:\SAMP Stuff\gamemodes\new.pwn(229) : error 029: invalid expression, assumed zero
S:\SAMP Stuff\gamemodes\new.pwn(230) : error 029: invalid expression, assumed zero
S:\SAMP Stuff\gamemodes\new.pwn(230) : error 029: invalid expression, assumed zero
S:\SAMP Stuff\gamemodes\new.pwn(230) : error 029: invalid expression, assumed zero
S:\SAMP Stuff\gamemodes\new.pwn(230) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


6 Errors.
Code Under OnGameModeInit for MySQL.

Код:
 options_id = mysql_init_options();
	DBConnect = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASS, MYSQL_DB, options_id);
	mysql_set_option(options_id, AUTO_RECONNECT, false);
	
	if(DBConnect == MYSQL_INVALID_HANDLE || mysql_errno(DBConnect) != 0)
        { //Line 229
                print("Connection to MySQL Database unsucessful. Exiting...."); //Line 230
		SendRconCommand("Exit");
		return 1;
        }
I am using MySQL R41-4 latest from BlueG. all other plugins are latest too as I downloaded them all today. all global variables are declared correctly at the top. any help is appreciated.


EDIT: I tried removing
Код:
 MySQL_errorno(DBConnect)
from if condition as I didn't see it in R40 Wiki. but still, same error..

EDIT 2: I'm stupid, its MySQL_errno not MySQL_errorno.... nevermind my first edit.
Reply
#2

Anyone to help?
Reply
#3

Someone? Help me? Please?
Reply
#4

bump......
Reply
#5

Hey I've taken your code and tried it in the below format which seems to work, could you possibly try this?
Код:
	new MySQLOpt:options_id = mysql_init_options();
	mysql_set_option(options_id, AUTO_RECONNECT, false);

	DBConnect = mysql_connect((MYSQL_HOST, MYSQL_USER, MYSQL_PASS, MYSQL_DB, options_id);
	if(mysql_errno(DBConnect ) != 0 || DBConnect == MYSQL_INVALID_HANDLE)
	{
	    print("\n----------------------------------------------------");
		print("[ERROR] Cannot establish connection to MySQL database!");
		printf("[MYSQL] ERROR CODE: %d", mysql_errno(DBConnect ));
		print("----------------------------------------------------");
	}
	else
	{
	    print("[MYSQL] Connection to MySQL database established successfully!");
	}
Reply
#6

Quote:
Originally Posted by MEW273
Посмотреть сообщение
Hey I've taken your code and tried it in the below format which seems to work, could you possibly try this?
Код:
	new MySQLOpt:options_id = mysql_init_options();
	mysql_set_option(options_id, AUTO_RECONNECT, false);

	DBConnect = mysql_connect((MYSQL_HOST, MYSQL_USER, MYSQL_PASS, MYSQL_DB, options_id);
	if(mysql_errno(DBConnect ) != 0 || DBConnect == MYSQL_INVALID_HANDLE)
	{
	    print("\n----------------------------------------------------");
		print("[ERROR] Cannot establish connection to MySQL database!");
		printf("[MYSQL] ERROR CODE: %d", mysql_errno(DBConnect ));
		print("----------------------------------------------------");
	}
	else
	{
	    print("[MYSQL] Connection to MySQL database established successfully!");
	}
The above code should work for you. and if doesnot,,
try this:

PHP код:
if(DBConnect && mysql_errno(DBConnect) == 0)
    {
        
printf("[MySQL]: Connection to database  successfully established!");
    }
    else
    {
        
printf("[MySQL]: Connection to database failed!");
    } 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)