Creating tables using strcat
#1

pawn Код:
strcat(query, "CREATE TABLE IF NOT EXISTS `playerdata` (`ID` INT(11) NOT NULL AUTO_INCREMENT, `Username` VARCHAR(24) NOT NULL, `Password` VARCHAR(40) NOT NULL, `Salt` VARCHAR(30) NOT NULL, `Gender` VARCHAR(24) NOT NULL, `Cash` INT(20) NOT NULL, `Bank` INT(20) NOT NULL, `BankReg` INT(10) NOT NULL,");
    strcat(query, "`Level` INT(10) NOT NULL, `Skin` INT(10) NOT NULL, `Admin` INT(10) NOT NULL, `AdminDuty` INT(10) NOT NULL, `Owner` INT(10) NOT NULL, `Job` INT(10) NOT NULL, `Interior` INT(10) NOT NULL, `VirtualWorld` INT(10) NOT NULL, `NewbMute` INT(10) NOT NULL, `GetHouseID` INT(10) NOT NULL, `VehID` INT(10) NOT NULL,");
    strcat(query, "`VehName` INT(10) NOT NULL, `VehX` float NOT NULL, `VehY` float NOT NULL, `VehZ` float NOT NULL, `VehA` float NOT NULL, `Veh2ID` INT(10) NOT NULL, `Veh2Name` INT(10) NOT NULL, `Veh2X` float NOT NULL, `Veh2Y` float NOT NULL, `Veh2Z` float NOT NULL, `Veh2A` float NOT NULL, `PosX` float NOT NULL,");
    strcat(query, "`PosY` float NOT NULL, `PosZ` float NOT NULL, `PosA` float NOT NULL)");
    mysql_function_query(dbHandle, query, false, "SendQuery", "");
What's wrong with this? It compiles fine just doesn't create the tables when I load up the game mode <.<
Reply
#2

Is the query's size enough to store the whole text?

Moreover, debugging is always helpful:
pawn Код:
strcat(query, "CREATE TABLE IF NOT EXISTS `playerdata` (`ID` INT(11) NOT NULL AUTO_INCREMENT, `Username` VARCHAR(24) NOT NULL, `Password` VARCHAR(40) NOT NULL, `Salt` VARCHAR(30) NOT NULL, `Gender` VARCHAR(24) NOT NULL, `Cash` INT(20) NOT NULL, `Bank` INT(20) NOT NULL, `BankReg` INT(10) NOT NULL,");
    strcat(query, "`Level` INT(10) NOT NULL, `Skin` INT(10) NOT NULL, `Admin` INT(10) NOT NULL, `AdminDuty` INT(10) NOT NULL, `Owner` INT(10) NOT NULL, `Job` INT(10) NOT NULL, `Interior` INT(10) NOT NULL, `VirtualWorld` INT(10) NOT NULL, `NewbMute` INT(10) NOT NULL, `GetHouseID` INT(10) NOT NULL, `VehID` INT(10) NOT NULL,");
strcat(query, "`VehName` INT(10) NOT NULL, `VehX` float NOT NULL, `VehY` float NOT NULL, `VehZ` float NOT NULL, `VehA` float NOT NULL, `Veh2ID` INT(10) NOT NULL, `Veh2Name` INT(10) NOT NULL, `Veh2X` float NOT NULL, `Veh2Y` float NOT NULL, `Veh2Z` float NOT NULL, `Veh2A` float NOT NULL, `PosX` float NOT NULL,");
strcat(query, "`PosY` float NOT NULL, `PosZ` float NOT NULL, `PosA` float NOT NULL)");
mysql_function_query(dbHandle, query, false, "SendQuery", "");
print(query); // DEBUG MESSAGE
Copy the output and run it in phpMyAdmin. If there's any syntax error, then it will give you results.
Reply
#3

Thanks Konstantinos, your method worked for playerdata, but now my houses isn't creating the table. I've ran it in query and it creates successfully.

pawn Код:
/* --- Player Data --- */

    strcat(query, "CREATE TABLE IF NOT EXISTS `playerdata` (`ID` INT(10) NOT NULL AUTO_INCREMENT, `Username` VARCHAR(24) NOT NULL, `Password` VARCHAR(40) NOT NULL, `Salt` VARCHAR(30) NOT NULL, `Gender` VARCHAR(24) NOT NULL, `Cash` INT(20) NOT NULL, `Bank` INT(20) NOT NULL, `BankReg` INT(10) NOT NULL,");
    strcat(query, "`Level` INT(10) NOT NULL, `Skin` INT(10) NOT NULL, `Admin` INT(10) NOT NULL, `AdminDuty` INT(10) NOT NULL, `Owner` INT(10) NOT NULL, `Job` INT(10) NOT NULL, `Interior` INT(10) NOT NULL, `VirtualWorld` INT(10) NOT NULL, `NewbMute` INT(10) NOT NULL, `GetHouseID` INT(10) NOT NULL, `VehID` INT(10) NOT NULL,");
    strcat(query, "`VehName` INT(10) NOT NULL, `VehX` float NOT NULL, `VehY` float NOT NULL, `VehZ` float NOT NULL, `VehA` float NOT NULL, `Veh2ID` INT(10) NOT NULL, `Veh2Name` INT(10) NOT NULL, `Veh2X` float NOT NULL, `Veh2Y` float NOT NULL, `Veh2Z` float NOT NULL, `Veh2A` float NOT NULL, `PosX` float NOT NULL,");
    strcat(query, "`PosY` float NOT NULL, `PosZ` float NOT NULL, `PosA` float NOT NULL, PRIMARY KEY (`ID`))");
    mysql_function_query(dbHandle, query, false, "SendQuery", "");

    /* --- House Data --- */ <--- this one

    strcat(query, "CREATE TABLE IF NOT EXISTS `houses` (`ID` INT(10) NOT NULL, `Address` VARCHAR(40) NOT NULL, `Owner` VARCHAR(24) NOT NULL, `Price` INT(20) NOT NULL, `Interior` INT(10) NOT NULL, `VirtualWorld` INT(10) NOT NULL, `PosX` float NOT NULL, `PosY` float NOT NULL, `PosZ` float NOT NULL,");
    strcat(query, "`EnterX` float NOT NULL, `EnterY` float NOT NULL, `EnterZ` float NOT NULL, `EnterA` float NOT NULL, `ExitX` float NOT NULL, `ExitY` float NOT NULL, `ExitZ` float NOT NULL, `ExitA` float NOT NULL, `Type` INT(10) NOT NULL)");
    mysql_function_query(dbHandle, query, false, "SendQuery", "");
Reply
#4

Hm.. if it creates the table (houses) successfully in phpMyAdmin and the size is not the problem, since the playerdata is larger and it created it, then I'm not so sure to be honest. Try checking the mysql log file, it might gives any information.
Reply
#5

Nevermind, fixed. I put the create table for houses in my SendQuery callback, but here is something that doesn't work for me using MySQL R8 and without it is harder:

pawn Код:
C:\Users\Mike\Desktop\FA-RP\gamemodes\MySQL.pwn(393) : error 017: undefined symbol "mysql_debug"

mysql_debug(1);
Reply
#6

I'm sure your a_mysql.inc is not the R8.

mysql_debug was removed in r21. So you include is r21+
Reply
#7

So the latest is R33 right?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)