Raised This Month: $ Target: $400
 0% 

dbi_query : variable help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MusicSpeed
New Member
Join Date: Oct 2009
Old 11-02-2009 , 18:04   dbi_query : variable help
Reply With Quote #1

Hi,

I need help on a basic problem (too easy for you maybe ^^).
I don't know how to put variable in SQL Queries by using dbi_query
Here is an example (this is just the problem part i know that i need a dbi_connect ):
Code:
new steamid[35]; get_user_authid(id,steamid,34);   new player_load:res = dbi_query(mysql, "SELECT * FROM mytable WHERE player_steamid = steamid")

I want to know if this code is correct because, if a user connect with a steamid for example STEAM_0:0:123456, the sql query will search for steamid and won't search for STEAM_0:0:123456. (it will search for the variable name and won't search for the variable content)

Thanks a lot and tell if i'm not really understandable

MusicSpeed

Last edited by MusicSpeed; 11-03-2009 at 04:00.
MusicSpeed is offline
unnyquee
Senior Member
Join Date: Jun 2009
Location: Constanta, Romania
Old 11-03-2009 , 07:41   Re: dbi_query : variable help
Reply With Quote #2

PHP Code:
new steamid[35]; 
get_user_authid(id,steamid,34); 

new 
szQuery[128];
format(szQuerycharsmax(szQuery), "SELECT * FROM mytable WHERE player_steamid = %s"steamid);

new 
player_load:res dbi_query(mysqlszQuery); 
Hope will that do the trick
__________________
unnyquee is offline
MusicSpeed
New Member
Join Date: Oct 2009
Old 11-03-2009 , 07:44   Re: dbi_query : variable help
Reply With Quote #3

Thanks a lot, now i know that i can use %s in a SQL Query ^^
+Karma

I've just another question, do you know how to create my own include file because with pawn studio i created one, added natives and this code at the top
but it didn't recognize it

(myincludefile.inc)
Code:
#if defined _myincludefile_included   #endinput #endif #define _myincludefile_included #include <amxmodx> #include <amxmisc>

MusicSpeed
__________________

Last edited by MusicSpeed; 11-03-2009 at 07:48.
MusicSpeed is offline
unnyquee
Senior Member
Join Date: Jun 2009
Location: Constanta, Romania
Old 11-03-2009 , 07:47   Re: dbi_query : variable help
Reply With Quote #4

Glad that I could help
Good luck in your future works
( btw, thx 4 k.. you deserve one too )

Edit:
Try this:
PHP Code:
#define _myincludefile_included
#if !defined _myincludefile_included
  #endinput
#endif

#include <amxmodx>
#include <amxmisc> 
Second Edit:
PHP Code:
new steamid[35]; 
get_user_authid(id,steamid,34); 

new 
szQuery[128];
format(szQuerycharsmax(szQuery), "SELECT * FROM `mytable` WHERE `player_steamid` = '%s'"steamid);

new 
player_load:res dbi_query(mysqlszQuery); 
Forgot quotes
__________________

Last edited by unnyquee; 11-03-2009 at 09:06.
unnyquee is offline
MusicSpeed
New Member
Join Date: Oct 2009
Old 11-03-2009 , 10:56   Re: dbi_query : variable help
Reply With Quote #5

Thank you for answering me !
All is allright now
__________________
MusicSpeed is offline
Reply



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

Forum Jump


All times are GMT -4. The time now is 09:08.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode