[ HELP ] Couldn't Connecting to MYSQL . Why?
#1

Hellu.
My server isn't Connecting to MYSQL why?

Here are the Codes ,

pawn Код:
forward ConnectMySQL()
public ConnectMySQL()
{
eXs=mysql_connect("127.0.0.1","port_2473", "port_2473", "etc")
//example eXs=mysql_connect("127.0.0.1","gtaserver4279", "gtaserver4279", "maybefuckoff")
printf("%d",mysql_errno(eXs))
if(mysql_errno() == 0)
{
mysql_close(eXs)
printf("[MYSQL]: [ERROR]:first Connection to `DATABASE` failed!")
eXs=mysql_connect("127.0.0.1","your username here", "YOUR DATABASE NAME HERE", "YOUR PASSWORD of user here")
//example eXs=mysql_connect("127.0.0.1","gtaserver4279", "gtaserver4279", "maybefuckoff")
printf("%d",mysql_errno(eXs))
if(mysql_errno() == 0)
{
mysql_close(eXs)
printf("[MYSQL]: [ERROR]:Second Connection to `DATABASE` failed!")
}
else
{
//mysql_log(LOG_ERROR | LOG_WARNING | LOG_DEBUG)
printf("[MYSQL]:second Connection to `DATABASE` successful! || %d",eXs)
con=2
}
}
else
{
//mysql_log(LOG_ERROR | LOG_WARNING | LOG_DEBUG)
printf("[MYSQL]:first Connection to `DATABASE` successful! || %d",eXs)
con=1
}
return 1
}
Reply
#2

Totally wrong.
if(mysql_errno(connectionHandle) == 0) // success
just do it in vice-versa
Reply
#3

Now wht?

pawn Код:
: error 017: undefined symbol "connectionHandle"
Reply
#4

pawn Код:
new connectionHandle;
Reply
#5

If mysql_errno return 0, there aren't errors.

pawn Код:
if(mysql_errno() == 0)
    print("No problem with the connection!");
Quote:
Originally Posted by biker122
Посмотреть сообщение
Totally wrong.
if(mysql_errno(connectionHandle) == 0) // success
just do it in vice-versa
mysql_errno hasn't parameters
Reply
#6

Quote:
Originally Posted by Dutheil
Посмотреть сообщение
If mysql_errno return 0, there aren't errors.

pawn Код:
print("No problem with the connection!");
i was already using this but couldn't connect to mysql!
Reply
#7

What version mysql do you use ?
Reply
#8

mysql plugin R39-2
Reply
#9

The mysql version works like that :

pawn Код:
// top of your script
new mysql;

// In OnGameModeInit
mysql = mysql_connect(the parameters);

// Exemple
public OnPlayerConnect(playerid)
{
    new pName[MAX_PLAYER_NAME], query[128];
    GetPlayerName(playerid, pName, sizeof(pName));
   
    mysql_format(mysql, query, sizeof(query), "SELECT * FROM `Members` WHERE `Name`='%s'", pName);
    mysql_tquery(mysql, query, "OnConnection", "d", playerid);
   
    return 1;
}

forward OnConnection(playerid);
public OnConnection(playerid)
{
    if(cache_get_row_count()) // an account find
    {
        // actions
    }

    else // account didn't find
    {
        // actions
    }
}
Reply
#10

https://sampwiki.blast.hk/wiki/MySQL#mysql_errno
Jump to mysql_errno
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)