Raised This Month: $ Target: $400
 0% 

SQLx - Can't connect with database.


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
fezh
Veteran Member
Join Date: Dec 2008
Location: BANNED
Old 08-25-2009 , 13:07   SQLx - Can't connect with database.
Reply With Quote #1

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <sqlx>

new cvar_hostname
new HandlegSqlTuple
new HandleSqlConnection
new gError[512]
new 
ErrorCode

public plugin_init()
{
    
register_plugin("SQLx Test""0.1.1""fezh")

    
register_concmd("sqlx_test""concmd_test")

    
cvar_hostname get_cvar_pointer("hostname")

    
set_task(0.5"sql_init")
}

public 
sql_init()
{
    
gSqlTuple SQL_MakeDbTuple("xxxx.thost.com.ar""enzo_xxxxxxx""xxxxxxx""enzo_xxxxxxxxxxx")
    
SqlConnection SQL_Connect(gSqlTupleErrorCodegError511)

    if (
SqlConnection == Empty_Handle)
    {
        
set_fail_state(gError)
    }

    new 
HandleQuery SQL_PrepareQuery(SqlConnection"CREATE TABLE IF NOT EXISTS `sqlx_amxx` (`hostname` VARCHAR(33), `date` VARCHAR(33)")

    if (!
SQL_Execute(Query))
    {
        
SQL_QueryError(QuerygError511)
        
set_fail_state(gError)
    }
}

public 
concmd_test(id)
{
    new 
servername[64], time[32]
    
get_pcvar_string(cvar_hostnameservernamecharsmax(servername))
    
get_time("%d/%m/%Y - %H:%M:%S"timecharsmax(time))

    new 
HandleQuery SQL_PrepareQuery(SqlConnection"INSERT INTO `sqlx_amxx` VALUES ('%s', '%s')"servernametime)
    
    if (!
SQL_Execute(Query))
    {
        
SQL_QueryError(QuerygError511)
        
set_fail_state(gError)
    }

    
SQL_FreeHandle(Query)
    
SQL_FreeHandle(SqlConnection)

Is there something bad in this code or is only a problem with web hosting?
__________________
"There is no knowledge, that is not power"
fezh is offline
 



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 15:09.


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