Raised This Month: $ Target: $400
 0% 

[SOLVED] [MySQL] select problem.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
AngeIII
Senior Member
Join Date: Sep 2007
Location: Latvia
Old 11-18-2010 , 21:40   [SOLVED] [MySQL] select problem.
Reply With Quote #1

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'); 

Last edited by AngeIII; 11-19-2010 at 16:23. Reason: Thanks to Exolent[jNr]. Solved.
AngeIII is offline
Send a message via Skype™ to AngeIII
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 11-18-2010 , 22:29   Re: [MySQL] select problem.
Reply With Quote #2

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%%'"); 
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] 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 11:14.


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