SQL Query Failure
#1

pawn Код:
new query[500];
format(query, sizeof(query),"INSERT INTO `ownedcars` (`spawnid`, `Model`, `Location_X`, `Location_Y`, `Location_Z`, `Angle`, `Color_1`, `Color_2`, `Owner`, `Owned`, `Locked`, `PlateSet`, `Plate`, `Paintjob`, `Virtualworld`, `Component0`, `Component1`, `Component2`, `Component3`, `Component4`, `Component5`, `Component6`, `Component7`, `Component8`, `Component9`, `Component10`, `Component11`, `Component12`, `Component13`, `SecurityCode`) VALUES ('%d', '%d', '%f', '%f', '%f', '%f', '0', '1', '1', '%s', '1', '1', '0', '', '999', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '%d')", sid, vmodel, x, y, z, angle, sname, strval(pass));
mysql_query(query);
pawn Код:
C:\Users\matt\Desktop\Raven's Roleplay 0.3c\gamemodes\ugrp_sql.pwn(41100) : error 075: input line too long (after substitutions)
C:\Users\matt\Desktop\Raven'
s Roleplay 0.3c\gamemodes\ugrp_sql.pwn(41101) : error 037: invalid string (possibly non-terminated string)
C:\Users\matt\Desktop\Raven's Roleplay 0.3c\gamemodes\ugrp_sql.pwn(41101) : error 017: undefined symbol "INSERT"
C:\Users\matt\Desktop\Raven'
s Roleplay 0.3c\gamemodes\ugrp_sql.pwn(41101) : error 017: undefined symbol "INTO"
C:\Users\matt\Desktop\Raven's Roleplay 0.3c\gamemodes\ugrp_sql.pwn(41101) : fatal error 107: too many error messages on one line
What's wrong there? - It says something's wrong?
Reply
#2

The input line is to long for the compiler.

Use STRCAT for that string.

Tip: 0 values doesn't need to be setted. Insert will create INT's as 0 as far as I know.
Reply
#3

Quote:
Originally Posted by arakuta
Посмотреть сообщение
The input line is to long for the compiler.

Use STRCAT for that string.

Tip: 0 values doesn't need to be setted. Insert will create INT's as 0 as far as I know.
What would I replace?

format(query, sizeof(query) > strcat(query, ? Instead of sizeof?
Reply
#4

First of all use what arakuta says in create table ... Color_1 TINYINT(3) default 0, Color_2 TINYINT(3) default 0 ... rest, then you dont need in insert color_1 and color_2

result
pawn Код:
format(query, sizeof(query),"INSERT INTO `ownedcars` (`spawnid`, `Model`, `Location_X`, `Location_Y`, `Location_Z`, `Angle`, `Owned`, `Paintjob`, `SecurityCode`) VALUES ('%d', '%d', '%f', '%f', '%f', '%f', '%s', '999', '%d')", sid, vmodel, x, y, z, angle, sname, strval(pass));
Second

pawn Код:
query = "INSERT INTO `ownedcars` (`spawnid`, `Model`, `Location_X`, `Location_Y`, `Location_Z`, `Angle`, `Color_1`, `Color_2`, `Owner`, `Owned`, `Locked`, `PlateSet`, `Plate`, `Paintjob`, `Virtualworld`, `Component0`, `Component1`, `Component2`, `Component3`, `Component4`";
strcat(query,",`Component5`, `Component6`, `Component7`, `Component8`, `Component9`, `Component10`, `Component11`, `Component12`, `Component13`, `SecurityCode`) VALUES");
format(query, sizeof(query),"%s('%d', '%d', '%f', '%f', '%f', '%f', '0', '1', '1', '%s', '1', '1', '0', '0', '999', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '%d')", query, sid, vmodel, x, y, z, angle, sname, strval(pass));
Reply
#5

don't need a strcat....

pawn Код:
new query[500];
format(query, sizeof(query),"INSERT INTO `ownedcars` (`spawnid`, `Model`, `Location_X`, `Location_Y`, `Location_Z`, `Angle`, `Color_1`, `Color_2`, `Owner`, `Owned`, `Locked`, `PlateSet`, `Plate`, `Paintjob`,\
`Virtualworld`, `Component0`, `Component1`, `Component2`, `Component3`, `Component4`, `Component5`, \
`Component6`, `Component7`, `Component8`, `Component9`, `Component10`, `Component11`, \
`Component12`, `Component13`, `SecurityCode`) VALUES ('%d', '%d', '%f', '%f', '%f', '%f', '0', '1', '1', '%s', '1', \
'1', '0', '', '999', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '%d')"
, sid, vmodel, x, y, z, angle, sname, strval(pass));
mysql_query(query);
Reply
#6

Got that done, The cars save perfectly now. The loading is the issue... There's 2 rows in DB atm.

pawn Код:
public LoadCar()
{
    new query[90], rows;
    format(query, sizeof(query),"SELECT COUNT(*) FROM ownedcars");
    mysql_query(query);
    mysql_store_result();
    rows = mysql_num_rows();
    printf("[MYSQL-DATABASE]: Loaded %d Vehicles (Dynamic)", rows);
    mysql_free_result();
    return 1;
}
That shows there's 0 Vehicles loading. That's the most basic loading function I know for it to count, what's wrong there?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)