Check player name in mysql and load an integer value from mysql
Hello, I would like to make following:
First, get player name and check if it exists in database (for example in column NAME). If it does exist, extract integer value from that row (let's say from column ID) and print in into chat as %i. Thank you. |
Re: Check player name in mysql and load an integer value from mysql
If you are seeking just for mysql syntax here you go
Code:
SELECT Id from `database.table` WHERE `name` like '%s'; |
Re: Check player name in mysql and load an integer value from mysql
Thank you, but my problem is whole pawn function. I have no experience with mysql in pawn.
|
Re: Check player name in mysql and load an integer value from mysql
The SQL is covered, and you can follow the framework from info in this thread: https://forums.alliedmods.net/showpo...58&postcount=2
|
Re: Check player name in mysql and load an integer value from mysql
From bugsy's code, edit it as you need (not tested):
PHP Code:
|
Re: Check player name in mysql and load an integer value from mysql
Quote:
So the case remains, if "username" is in database, extract the integer value of "days" from that row and client_print it into %i. No idea how to continue. https://i.ibb.co/Rpz2rzG/xix.png |
Re: Check player name in mysql and load an integer value from mysql
Quote:
PHP Code:
Here a little debug to check: PHP Code:
|
Re: Check player name in mysql and load an integer value from mysql
Quote:
Also I changed Code:
SELECT * FROM table WHERE username='%s'And I would like to extract value from it, for example 10. //edit: Got it, thank you many times. The issue was Code:
client_print(id, print_chat, "Day: %d", g_iValue[id]); |
Re: Check player name in mysql and load an integer value from mysql
You should use steam id instead of name. Also, if the name has a ' character in it, it will make your SQL lookup fail.
SELECT * FROM Table WHERE name='bugsy 'test'' |
Re: Check player name in mysql and load an integer value from mysql
Quote:
|
| All times are GMT -4. The time now is 07:31. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.