MySQL Varibles Returning Problem
#1

I've been coding an autologin system but I have a problem. It retrives the details from the database but when it splits it up and assigns it to varibles it stops the rest of the code running; As soon as a varible is going to be assigned its like a return, It stops the rest of the code.


http://pastebin.com/euy9WMK1



Thanks.
Reply
#2

Can't get why did you use the split function to get only the player's IP, a query is enaugh, by the way
pawn Код:
new
    query[128],
    name[24],
    escpname[24],
    IP[16];
GetPlayerName(playerid, name, sizeof name);
GetPlayerIp(playerid, IP, sizeof IP);
mysql_real_escape_string(name, escpname);
format(query, sizeof(query), "SELECT * FROM `users` WHERE `Name` = '%s' AND `IP` = '%s'", escpname, IP);
mysql_query(query);
mysql_store_result();
if(mysql_num_rows() != 0) {
    //Player is auto ip logined
}
Reply
#3

Either way, why do you select all of the information in that row if you're not going to use it? Just select the column that you're trying to get.
Reply
#4

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
Either way, why do you select all of the information in that row if you're not going to use it? Just select the column that you're trying to get.
How to? I guess it's always needed to select a row and a column, to get the right value
Reply
#5

Well in his code he was originally selecting everything, but only using a single value:

pawn Код:
UserStats[playerid][Admin] = strval(field[2]);
That's all that was in the snippet anyway, so if he was just going to use that value, why select everything? Just select admin or whatever you called that column.

pawn Код:
"SELECT ColumName FROM `table` WHERE Name = 'something'"
Reply
#6

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
Well in his code he was originally selecting everything, but only using a single value:

pawn Код:
UserStats[playerid][Admin] = strval(field[2]);
That's all that was in the snippet anyway, so if he was just going to use that value, why select everything? Just select admin or whatever you called that column.

pawn Код:
"SELECT ColumName FROM `table` WHERE Name = 'something'"
You need to wrap 'grave accents' (`) around each column/field if you use one in your query, otherwise the query won't work.
Reply
#7

Quote:
Originally Posted by Calg00ne
Посмотреть сообщение
You need to wrap 'grave accents' (`) around each column/field if you use one in your query, otherwise the query won't work.
I never do and it works fine.
Reply
#8

I've helped quite a few people fix their queries by wrapping columns/field names appropriately, so that's odd.
Reply
#9

I think it has to do with your query try this
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)