AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Mysql query and text in db (https://forums.alliedmods.net/showthread.php?t=89773)

asdcoolpix 04-10-2009 10:21

Mysql query and text in db
 
All greetings. For me a small problem. To a database to be stored in a cell the number. By operation of the given code all passes as it is necessary. The result is displayed in the server console. I wish to output the text from a cell and to display it in the console. At inquiry there is unit or a zero, and it would be necessary that value of a cell was displayed.

PHP Code:

public xxx(){

    new  
error[256]
    new 
ErrorCode
    g_SqlTuple 
SQL_MakeDbTuple(H_HOST,H_USER,H_PASS,H_DB)
    
SqlConnection SQL_Connect(g_SqlTuple,ErrorCode,error,255)
    
    new 
Handle:Query SQL_PrepareQuery(SqlConnection"SELECT value FROM hmk_update WHERE type='huds'")
    
    if(!
SQL_Execute(Query))
    {
        
SQL_QueryError(Query,error,255)
        
server_print("[HOMKA QDB] Error: %s^n",error);
    }
    
server_print("[HOMKA QDB] NOT Error");
    new 
Data
    Data 
SQL_ReadResult(Query,0)
    
server_print("[HOMKA QDB] result: vakue  huds - %d",Data)



[IMG]http://img237.**************/img237/6158/fucktesttable.jpg[/IMG]
[IMG]http://img237.**************/img237/fucktesttable.jpg/1/w1680.png[/IMG]
:|

Hunter-Digital 04-10-2009 11:10

Re: Mysql query and text in db
 
use %s for strings, %d for numbers, %f for floats and so on :)

asdcoolpix 04-10-2009 11:18

Re: Mysql query and text in db
 
=(
now i am use %s

[IMG]http://img13.**************/img13/7826/fucktesttable2.jpg[/IMG]
[IMG]http://img13.**************/img13/fucktesttable2.jpg/1/w1680.png[/IMG]


and server print
Quote:

[HOMKA QDB] Результат: значение huds -
In what there can be a business?

Nextra 04-10-2009 14:58

Re: Mysql query and text in db
 
Quote:

Originally Posted by asdcoolpix (Post 802243)
PHP Code:

public xxx(){

    new  
error[256]
    new 
ErrorCode
    g_SqlTuple 
SQL_MakeDbTuple(H_HOST,H_USER,H_PASS,H_DB)
    
SqlConnection SQL_Connect(g_SqlTuple,ErrorCode,error,255)
    
    new 
Handle:Query SQL_PrepareQuery(SqlConnection"SELECT value FROM hmk_update WHERE type='huds'")
    
    if(!
SQL_Execute(Query))
    {
        
SQL_QueryError(Query,error,255)
        
server_print("[HOMKA QDB] Error: %s^n",error);
    }
    
server_print("[HOMKA QDB] NOT Error");
    new 
Data
    Data 
SQL_ReadResult(Query,0)
    
server_print("[HOMKA QDB] result: vakue  huds - %d",Data)




-->

PHP Code:

public xxx(){

    new  
error[256]
    new 
ErrorCode
    g_SqlTuple 
SQL_MakeDbTuple(H_HOST,H_USER,H_PASS,H_DB)
    
SqlConnection SQL_Connect(g_SqlTuple,ErrorCode,error,255)
    
    new 
Handle:Query SQL_PrepareQuery(SqlConnection"SELECT value FROM hmk_update WHERE type='huds'")
    
    if(!
SQL_Execute(Query))
    {
        
SQL_QueryError(Query,error,255)
        
server_print("[HOMKA QDB] Error: %s^n",error);
    }
    
server_print("[HOMKA QDB] NOT Error");
    new 
szData[32]
    
SQL_ReadResult(Query,0szData31)
    
server_print("[HOMKA QDB] result: vakue  huds - %s",Data)




joaquimandrade 04-10-2009 15:01

Re: Mysql query and text in db
 
PHP Code:

new Data[10]
SQL_ReadResult(Query,0,Data,9



All times are GMT -4. The time now is 02:21.

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