SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 17/05/2020, 05:05 PM   #1
Marroquin
Little Clucker
 
Join Date: Oct 2018
Posts: 8
Reputation: 0
Default [MYSQL] Help to extract a data

I had already created a topic, but I decided to delete it because it did not explain very well so I create it again explaining well what is happening to me.

When it comes to recovering the data from the database, it happens to me that if I leave "0" in this line:
cache_get_value_int (0, "Arma1", a);
He always extracts the player's weapons from column 0, which as you can see is "Carlos_Marroquin". I want "0" to be chosen according to the player who enters, I have the variable "ID_WEAPON" which increases as the Players, how can I get the data of that row, to use it instead of "0"?
I leave the photos of everything down here


This is inside another function that is called from OnPlayerConnect when a player logs correctly.

Marroquin is offline   Reply With Quote
Old 17/05/2020, 05:57 PM   #2
Mugala
High-roller
 
Mugala's Avatar
 
Join Date: Nov 2012
Location: Georgia, Tbilisi
Posts: 1,176
Reputation: 73
Default Re: [MYSQL] Help to extract a data

Hello, you have to change MySQL query, to detect that, you have to use
PHP Code:
SELECT `ID_WEAPONFROM `PLAYER_WEAPONSWHERE `NAME_USER` = '%s' 
%s means PlayerName(playerid)
__________________
Coding in 8 languages including Pawn, C#, C++ and SQL.
Available for hiring.

If you have a coding question or need an assistance in a code, just PM me.
If you want me to create something for you, here is a Discord Mugala#5651

Currently helping Community members in a coding.
Mugala is offline   Reply With Quote
Old 17/05/2020, 05:59 PM   #3
Adamoneoone
Huge Clucker
 
Join Date: Sep 2014
Posts: 485
Reputation: 37
Default Re: [MYSQL] Help to extract a data

You should use %e instead of %s or escape the string first to avoid any SQL Injection.
__________________
If you want to have your own custom script, or even want to have one of our already released scripts, join our SCRIPTING SERVICES DISCORD, or send me a private message!
Adamoneoone is offline   Reply With Quote
Old 17/05/2020, 10:31 PM   #4
Marroquin
Little Clucker
 
Join Date: Oct 2018
Posts: 8
Reputation: 0
Default Re: [MYSQL] Help to extract a data

Quote:
Originally Posted by Mugala View Post
Hello, you have to change MySQL query, to detect that, you have to use
PHP Code:
SELECT `ID_WEAPONFROM `PLAYER_WEAPONSWHERE `NAME_USER` = '%s' 
%s means PlayerName(playerid)
Muchas gracias, esto me solucionů el problema
Marroquin is offline   Reply With Quote
Old 17/05/2020, 10:37 PM   #5
Marroquin
Little Clucker
 
Join Date: Oct 2018
Posts: 8
Reputation: 0
Default Re: [MYSQL] Help to extract a data

Quote:
Originally Posted by Mugala View Post
Hello, you have to change MySQL query, to detect that, you have to use
PHP Code:
SELECT `ID_WEAPONFROM `PLAYER_WEAPONSWHERE `NAME_USER` = '%s' 
%s means PlayerName(playerid)
Thank you very much, this solved the problem for me
Marroquin is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
MySQL fetching data error invalid data type - NULL Hargrave Scripting Help 1 16/07/2016 04:23 PM
UCP extract ajam123 Server Support 3 23/03/2013 02:05 PM
MySQL bad extract?! gabyk Scripting Help 4 29/10/2012 04:11 PM


All times are GMT. The time now is 04:18 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.