SA-MP Forums Archive
/createhouse mysql problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: /createhouse mysql problem (/showthread.php?tid=317429)



/createhouse mysql problem - GeonMake - 11.02.2012

pawn Код:
if(strcmp(cmd, "/createhouse", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            new Float:X, Float:Y, Float:Z;
            GetPlayerPos(playerid, X,Y,Z);
            new Int = 1;
            new Owner[256], Discription[256];
            format(Owner, sizeof(Owner), "The State");
            format(Discription, sizeof(Discription), "House Apartment");
            new Value = 45000;
            new Lock = 1;
            new Owned = 0;
            new World = 1;
            new Query[256];
            new x1 = 244.411987;
            new y1 = 305.032990;
            new z1 = 999.231995;
            new id;
            id = mysql_num_rows()+1;
            format(Query, sizeof(Query), "INSERT INTO `house` (`ID`, `Entrancex`, `Entrancey`, `Entrancez`, `Exitx`, `Exity`, `Exitz`, `Owner`, `Discription`, `Value`, `Int`, `Lock`, `Owned`, `World`) VALUES ('%d', '%f', '%f', '%f', '%f', '%f', '%f', '%s', '%s', '%d', '%d', '%d', '%d', '%d')", id, X,Y,Z,x1,y1,z1,Owner,Discription,Value,Int,Lock,Owned,World);
            mysql_query(Query);
            mysql_free_result();
            return 1;
        }
        return 1;
    }
It disn`t working..when i write this command is not insering in data base tabel.


Re: /createhouse mysql problem - Sufyan - 11.02.2012

Quote:

mysql_debug(1);

and see what is problem


Re: /createhouse mysql problem - GeonMake - 11.02.2012

pawn Код:
[16:48:53] CMySQLHandler::Query(INSERT INTO `house` (`ID`, `Entrancex`, `Entrancey`, `Entrancez`, `Exitx`, `Exity`, `Exitz`, `Owner`, `Discription`, `Value`, `Int`, `Lock`, `Owned`, `World`) VALUES ('0', '933.725830', '-1804.942138', '13.844137', '244.411987', '305.032989', '999.231994') - An error has occured. (Error ID: 1064, You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1)
[16:48:53] >> mysql_free_result( Connection handle: 1 )
[16:48:53] CMySQLHandler::FreeResult() - The result is already empty.



Re: /createhouse mysql problem - fordawinzz - 11.02.2012

try using id = mysql_insert_id();


Re: /createhouse mysql problem - Sufyan - 11.02.2012

id filled is Integer? if it is then use
Quote:

format(Query, sizeof(Query), "INSERT INTO `house` (`ID`, `Entrancex`, `Entrancey`, `Entrancez`, `Exitx`, `Exity`, `Exitz`, `Owner`, `Discription`, `Value`, `Int`, `Lock`, `Owned`, `World`) VALUES (%d, '%f', '%f', '%f', '%f', '%f', '%f', '%s', '%s', '%d', '%d', '%d', '%d', '%d')", id, X,Y,Z,x1,y1,z1,Owner,Discription,Value,Int,Lock,Ow ned,World);




Re: /createhouse mysql problem - GeonMake - 11.02.2012

Not working


Re: /createhouse mysql problem - fordawinzz - 11.02.2012

then set the id to AUTO_INCREMENT in the database


Re: /createhouse mysql problem - [MG]Dimi - 11.02.2012

Also understand one thing people: Saving Data or Making new row doesn't need mysql_free_result(); since it's not returning anything from mysql! And yes, delete your ID from query. In Table create Integer column and set auto-increment.


Re: /createhouse mysql problem - Rob_Maate - 11.02.2012

^^mysql_free_result(); expects parameters which you aren't supplying.

Since you haven't actually retrieved information from the database, obviously there is no result, meaning there's no result to free. Delete that line and have a go.


Re: /createhouse mysql problem - GeonMake - 11.02.2012

It doesn`t work..i don`t know why..maybe is from command?

pawn Код:
[01:23:03] CMySQLHandler::Query(INSERT INTO `house` (`ID`, `Entrancex`, `Entrancey`, `Entrancez`, `Exitx`, `Exity`, `Exitz`, `Owner`, `Discription`, `Value`, `Int`, `Lock`, `Owned`, `World`) VALUES ('0', '909.684692', '-1802.042968', '13.770242', '0.000000', '0.000000', '0.000000', 'The) - An error has occured. (Error ID: 1064, You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''The' at line 1)