AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   SQLx - Can't connect with database. (https://forums.alliedmods.net/showthread.php?t=101610)

fezh 08-25-2009 13:07

SQLx - Can't connect with database.
 
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?

Arkshine 08-25-2009 13:20

Re: SQLx - Can't connect with database.
 
Your SQL server accepts exterior connections ?

fezh 08-25-2009 13:22

Re: SQLx - Can't connect with database.
 
Quote:

Originally Posted by Arkshine (Post 912630)
Your SQL server accepts exterior connections ?

idk, i tried with some free hostings, maybe the problem is that i should pay :/

11101010 08-25-2009 13:29

Re: SQLx - Can't connect with database.
 
Quote:

Originally Posted by fezh (Post 912632)
idk, i tried with some free hostings, maybe the problem is that i should pay :/

Free host give localhost only


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

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