Too long MySQL Query
#1

Hi! What's up?
I'm trying to make a good RP GM.
I made a CREATE TABLE query, but I get error. Apparently, those errors saying that it's too long (that's what I've found out from trying).
The query:
pawn Код:
mysql_query("CREATE TABLE IF NOT EXISTS `users`(`id` INT NULL AUTO_INCREMENT,`username` VARCHAR(50) NOT NULL,`password` INT NOT NULL,`month` INT(2) NOT NULL,`day` INT(2) NOT NULL,`year` INT(4) NOT NULL,`origin` VARCHAR(50) NOT NULL,`payday` INT NOT NULL,`money` INT NOT NULL,`bankmoney` INT NOT NULL,`factionid` INT(2) NOT NULL,`factionranknum` INT(2) NOT NULL,`factionrank` VARCHAR(50) NOT NULL,`jobid` INT(2) NOT NULL,`level` INT(2) NOT NULL,`alevel` INT (1) NOT NULL,`phone` INT NOT NULL,PRIMARY KEY(`id`))");
Even after that, I'd like to add some more rows to the table...
The errors:
pawn Код:
NPP_SAVE: C:\Users\Lazri\Desktop\samp03dsvr_R2_win32\gamemodes\vb-rp.pwn
CD: C:\Users\Lazri\Desktop\samp03dsvr_R2_win32\gamemodes
Current directory: C:\Users\Lazri\Desktop\samp03dsvr_R2_win32\gamemodes
"C:\Users\Lazri\Desktop\samp03dsvr_R2_win32\pawno\pawncc.exe" "vb-rp.pwn"
Process started >>>
C:\Users\Lazri\Desktop\samp03dsvr_R2_win32\pawno\include\sscanf.inc(139) : warning 219: local variable "id" shadows a variable at a preceding level
vb-rp.pwn(166) : error 075: input line too long (after substitutions)
vb-rp.pwn(167) : error 037: invalid string (possibly non-terminated string)
vb-rp.pwn(167) : error 017: undefined symbol "CREATE"
vb-rp.pwn(167) : error 017: undefined symbol "IF"
vb-rp.pwn(167) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


5 Errors.
<<< Process finished.
================ READY ================
Reply
#2

show the code from line 166

I dont think its this query its only 512 chars
This is more of a text replacement error as far as I can tell,
or too much code on one line.
Reply
#3

Best way is too just create the tables in a GUI such as phpMyAdmin. You only need to create the table once, so it's basically a waste of resources if that query is executed every time the server starts.

If you intend to distribute the script, then use the export function of phpMyAdmin to generate appropriate SQL code. People that do not manage to re-import the code should not be running a server in the first place.
Reply
#4

Yeah, Vince.. You're actually right . I'll do it, thanks.
Reply
#5

i still dont think thats the problem!!
i have querys upto around 1000 chars,
this is a TEXT REPLACEMENT issue,
like you defined something

#define SomeString SomeReallyLongCodeHere

then in your code when it replaces SomeString your code is over 256 chars and gives this error,
I could be wrong...Wouldnt be the first time and most likely not the last
Reply
#6

Quote:
Originally Posted by Jonny5
Посмотреть сообщение
i still dont think thats the problem!!
i have querys upto around 1000 chars,
this is a TEXT REPLACEMENT issue,
like you defined something

#define SomeString SomeReallyLongCodeHere

then in your code when it replaces SomeString your code is over 256 chars and gives this error,
I could be wrong...Wouldnt be the first time and most likely not the last
Ehhh - you're not making any sense. I, personally, tell you if you still want to use that long SQL Query, consider doing this:

pawn Код:
new string[512];

format(string, sizeof(string), "CREATE TABLE IF NOT EXISTS `users`(`id` INT NULL AUTO_INCREMENT,`username` VARCHAR(50) NOT NULL,`password` INT NOT NULL,`month` INT(2) NOT NULL,`day` INT(2) NOT NULL,`year` INT(4) NOT NULL,`origin` VARCHAR(50) NOT NULL,`payday` INT NOT NULL,`money` INT NOT NULL,`bankmoney` INT NOT NULL,`factionid` INT(2) NOT NULL,`factionranknum` INT(2) NOT NULL,`factionrank` VARCHAR(50) NOT NULL,`jobid` INT(2) NOT NULL,`level` INT(2) NOT NULL,`alevel` INT (1) NOT NULL,`phone` INT NOT NULL,PRIMARY KEY(`id`))");
mysql_query(string);
Change the size of string (which is not recommended) to a higher value if the query still seems to be giving out errors.
Reply
#7

Thanks. Finally, I did what Vince said and it works just fine . It's also better in my opinion.
But thanks guys, I'll keep your comments in mind!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)