houses are not loading from database properly[REP +]
#1

pawn Код:
stock LoadProperty()
    {
    mysql_query("SELECT * FROM `houses` ORDER BY `houses`.`hid` ASC");
    mysql_store_result();
    new query[256];
    if(mysql_num_rows() > 0)
    {
    for(new idx = 0; idx < mysql_num_rows(); idx++)
    {
    mysql_fetch_row(query);
    sscanf(query,"p<|>ids[32]ffffffds[20]dds[64]d",
    HouseInfo[idx][hid],
    HouseInfo[idx][hOwned],
    HouseInfo[idx][hOwner],
    HouseInfo[idx][hEntrancex],
    HouseInfo[idx][hEntrancey],
    HouseInfo[idx][hEntrancez],
    HouseInfo[idx][hExitx],
    HouseInfo[idx][hExity],
    HouseInfo[idx][hExitz],
    HouseInfo[idx][hHealthx],
    HouseInfo[idx][hHealthy],
    HouseInfo[idx][hHealthz],
    HouseInfo[idx][hArmourx],
    HouseInfo[idx][hArmoury],
    HouseInfo[idx][hArmourz],
    HouseInfo[idx][hValue],
    HouseInfo[idx][hHel],
    HouseInfo[idx][hArm],
    HouseInfo[idx][hInt],
    HouseInfo[idx][hLock],
    HouseInfo[idx][hRooms],
    HouseInfo[idx][hRent],
    HouseInfo[idx][hRentabil],
    HouseInfo[idx][hTakings],
    HouseInfo[idx][hSetted],
    HouseInfo[idx][hLevel],
    HouseInfo[idx][hWorld],
    HouseInfo[idx][hDrugs],
    HouseInfo[idx][hMaterials],
    HouseInfo[idx][hWeapon1],
    HouseInfo[idx][hAmmo1],
    HouseInfo[idx][hWeapon2],
    HouseInfo[idx][hAmmo2],
    HouseInfo[idx][hWeapon3],
    HouseInfo[idx][hAmmo3],
    HouseInfo[idx][hWeapon4],
    HouseInfo[idx][hAmmo4],
    HouseInfo[idx][hWeapon5],
    HouseInfo[idx][hAmmo5],
    HouseInfo[idx][hWeapon6],
    HouseInfo[idx][hAmmo6],
    HouseInfo[idx][hMessage]);
    MAXHOUSES++;
    }
    }
    mysql_free_result(),
    printf("\nHouses From Database Loaded"),
    printf("\nInfo:Houses From Database:%d\n",MAXHOUSES);
    return 1;
}
Houses aren't loading from database properly
I know that I have mistake in this line
pawn Код:
sscanf(query,"p<|>ids[32]ffffffds[20]dds[64]d",
but I don't know how to fix it
Reply
#2

print what mysql_fetch_row is returning. See what you are giving sscanf.
Reply
#3

Quote:
Originally Posted by MP2
Посмотреть сообщение
print what mysql_fetch_row is returning. See what you are giving sscanf.
You mean this?
Код:
[21:35:32]  

[21:35:32] ---------------------------

[21:35:32] MySQL Debugging activated (02/10/12)

[21:35:32] ---------------------------

[21:35:32]  

[21:35:32] >> mysql_connect( )

[21:35:32] CMySQLHandler::CMySQLHandler() - constructor called.

[21:35:32] CMySQLHandler::CMySQLHandler() - Connecting to "localhost" | DB: "test" | Username: "root" ...

[21:35:32] CMySQLHandler::Connect() - Connection was successful.

[21:35:32] CMySQLHandler::Connect() - Auto-Reconnect has been enabled.

[21:35:32] >> mysql_ping( Connection handle: 1 )

[21:35:32] CMySQLHandler::Ping() - Connection is still alive.

[21:35:37] >> mysql_query( Connection handle: 1 )

[21:35:37] CMySQLHandler::Query(SELECT * FROM `houses` ORDER BY `houses`.`hid` ASC) - Successfully executed.

[21:35:37] >> mysql_store_result( Connection handle: 1 )

[21:35:37] CMySQLHandler::StoreResult() - Result was stored.

[21:35:37] >> mysql_num_rows( Connection handle: 1 )

[21:35:37] CMySQLHandler::NumRows() - Returned 2 row(s)

[21:35:37] >> mysql_num_rows( Connection handle: 1 )

[21:35:37] CMySQLHandler::NumRows() - Returned 2 row(s)

[21:35:37] >> mysql_fetch_row_format( Connection handle: 1 )

[21:35:37] CMySQLHandler::FetchRow() - Return: 0|0|The State|2457.35913|-1054.448608|59.742187|1.2|-3.4|999.400024|0|0|0|0|0|0|1|0|0|2|1|0|1|0|182|1|1|1|0|0|0|0|0|0|0|0|0|0|0|0|0|0|For Sale

[21:35:37] >> mysql_num_rows( Connection handle: 1 )

[21:35:37] CMySQLHandler::NumRows() - Returned 2 row(s)

[21:35:38] >> mysql_fetch_row_format( Connection handle: 1 )

[21:35:38] CMySQLHandler::FetchRow() - Return: 1|0|The State|2457.35913|-1054.448608|59.742187|223.192901|1287.078002|1082.140625|0|0|0|0|0|0|1|0|0|2|1|0|1|0|182|1|1|1|0|0|0|0|0|0|0|0|0|0|0|0|0|0|For Sale

[21:35:38] >> mysql_num_rows( Connection handle: 1 )

[21:35:38] CMySQLHandler::NumRows() - Returned 2 row(s)

[21:35:38] >> mysql_free_result( Connection handle: 1 )

[21:35:38] CMySQLHandler::FreeResult() - Result was successfully free'd.

[21:35:38] >> mysql_retrieve_row( Connection handle: 1 )

[21:35:38] CMySQLHandler::RetrieveRow() - You cannot call this function now. (Reason: Empty Result)
Reply
#4

Just Check the table is there or no
if not add it
Reply
#5

Код:
SA-MP Dedicated Server
----------------------
v0.3d, ©2005-2011 SA-MP Team

[21:51:17] filterscripts = ""  (string)
[21:51:17] 
[21:51:17] Server Plugins
[21:51:17] --------------
[21:51:17]  Loading plugin: streamer
[21:51:17] 

*** Streamer Plugin v2.5.2 by Incognito loaded ***

[21:51:17]   Loaded.
[21:51:17]  Loading plugin: mysql
[21:51:17] 

  > MySQL plugin R6-2 successfully loaded.

[21:51:17]   Loaded.
[21:51:17]  Loading plugin: sscanf
[21:51:17] 

[21:51:17]  ===============================

[21:51:17]       sscanf plugin loaded.     

[21:51:17]    © 2009 Alex "******" Cole

[21:51:17]  ===============================

[21:51:17]   Loaded.
[21:51:17]  Loaded 3 plugins.

[21:51:17] 
[21:51:17] Filterscripts
[21:51:17] ---------------
[21:51:17]   Loaded 0 filterscripts.

[21:51:17] foreach called
[21:51:18] MySQL: Connected sucesfull
[21:51:31] sscanf warning: Format specifier does not match parameter count.
[21:51:31] sscanf warning: Format specifier does not match parameter count.
[21:51:31] 
Houses From Database Loaded
[21:51:31] 
Info:Houses From Database:2
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)