AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [SOLVED] [MySQL] select problem. (https://forums.alliedmods.net/showthread.php?t=143381)

AngeIII 11-18-2010 21:40

[SOLVED] [MySQL] select problem.
 
Quote:

SOLVED!!:
You need to use %% to escape formatting.
Hello.

I have problem with:

PHP Code:

public check()
{
    new 
Handle:query;
    
    
query SQL_PrepareQueryg_DBConn"SELECT `hostname` FROM `amx_guard` WHERE `plugins` LIKE '%test%'");
    
    if ( !
SQL_Executequery ))
    {
        
log_amx"[Mysql] Can't execute query" );
        
SQL_FreeHandlequery );
        return 
PLUGIN_HANDLED;
    }
    if ( 
SQL_NumResults(query) == 0)
    {
        
log_amx"[Mysql] No-one result" );
        
SQL_FreeHandlequery );
        return 
PLUGIN_HANDLED;
    }    
    new 
str[32];
    
SQL_ReadResult(query0str254)
    
server_print"%s",str);
    
SQL_FreeHandlequery );
    return 
PLUGIN_CONTINUE;


WHERE `plugins` LIKE '%test%'

it's always get NULL result.

in php all ok.. but in-game not work.

how to select I dont know.. anyone can help?
db contain:
PHP Code:

CREATE TABLE IF NOT EXISTS `amx_guard` (
  `
idint(8NOT NULL auto_increment,
  `
hostnamevarchar(250) default NULL,
  `
pluginsvarchar(250) default NULL,
  
PRIMARY KEY  (`id`)
ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=;

INSERT INTO `amx_guard` (`id`, `hostname`, `plugins`) VALUES
(1'doit''war3ft.amxx, darkside.amxx, test.amxx'); 


Exolent[jNr] 11-18-2010 22:29

Re: [MySQL] select problem.
 
SQL_PrepareQuery() uses formatting, so you need to use %% to escape the formatting for your % signs.

PHP Code:

query SQL_PrepareQueryg_DBConn"SELECT `hostname` FROM `amx_guard` WHERE `plugins` LIKE '%%test%%'"); 



All times are GMT -4. The time now is 11:14.

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