{Help} Table not being created.
#1

PHP код:
CMD:createfaction(playeridparams[])
{
    if(
pInfo[playerid][pLevel] >= 5)
    {
            new 
id,name[50],fac FacCount;
            if(
sscanf(params,"us[50]",id,name)) return SCM(playerid,COLOR_ORANGE,"USAGE: /createfaction (playerid) (faction name)");
            if(
fac >= MAX_FACTIONS) return SCM(playerid,COLOR_RED,"Max faction limit reached!");
            if(
pInfo[id][flevel] == 0)
            {
            new 
Query[128];
            
format(Querysizeof(Query), "INSERT INTO `Faction` (`Name`, `ID`, `Owner`, `Levels`, `InviteRank`, `KickRank`) VALUES('%s', '%d', '%s', '%d', '%d', '%d')"nameFacCountPN(id), 1077);
            
db_query(DatabaseQuery);
            
pInfo[id][flevel] = 10;
            
pInfo[id][fname] = name;
            
pInfo[id][pfacno] = FacCount;
            
FactionInfo[fac][del] = 0;
            
SaveStatus(id);
            new 
string[120];
            
format(string,sizeof(string),"You created a faction for %s with name %s.",PN(id),name);
            
SCM(playerid,COLOR_YELLOW,string);
            
format(string,sizeof(string),"Administrator %s has created a faction for you with name %s.",PN(playerid),name);
            
SCM(id,COLOR_YELLOW,string);
            
FacCount++;
            }
    }
    return 
1;

The tables are not being created in the DB file. Any idea?
Reply
#2

This code does not create a table, it inserts into it. You need to create the table 'Faction' first. There's not much point in creating the table in your gamemode as it's likely that you'll only really need to create it once in its lifetime.

PHP код:
CREATE TABLE IF NOT EXISTS `Faction` ... 
Reply
#3

Yea i already have that code on ongamemodeinit everything is created just the values are not being inserted of the /createfaction
Reply
#4

Quote:
Originally Posted by Vince
Посмотреть сообщение
It's generally not worth the effort to create tables via Pawn. Just create the database and the table structure in phpMyAdmin or another GUI you might have.
Well..

And if you have problem just use this
PHP код:
mysql_log(ERROR WARNING); 
Reply
#5

I'm using sqlite and not mysql
Reply
#6

BUMP!
Reply
#7

BUMP!
Reply
#8

So the table exists but it doesn't insert a new row, the title is misleading.

Open server.cfg and add:
pawn Код:
db_logging 1
start the server, execute the command and post the server log.

And please don't bump within 24 hours, there are rules we all should follow.
Reply
#9

PHP код:
[16:30:05] [Warningdb_queryQuery failednear ","syntax error 
Only this error came
Reply
#10

Can you also add
pawn Код:
db_log_queries 1
in server.cfg and try again? If we have the query might be easier.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)