[MYSQL] Either queries or sscanf crash the server
#8

Okay sure. The problem is that it does not load the row that is actually there and reports an error back saying that the row is empty. While i have proof that they are not empty.
Heres the log:
Код:
[13:10:08] CMySQLHandler::Query(SELECT `HouseID` FROM `Houses` WHERE `Houseowner`='Thimo') - Successfully executed.

[13:10:08] >> mysql_store_result( Connection handle: 1 )

[13:10:08] CMySQLHandler::StoreResult() - Result was stored.

[13:10:08] >> mysql_fetch_field_row( Connection handle: 1 )

[13:10:08] CMySQLHandler::FetchField(HouseID) - You cannot call this function now. (Reason: Fields/Rows are empty.)

[13:10:08] >> mysql_free_result( Connection handle: 1 )

[13:10:08] CMySQLHandler::FreeResult() - Result was successfully free'd.
The code i am TRYING to excecute is this:

pawn Код:
format(str, sizeof(str), "SELECT `HouseID` FROM `Houses` WHERE `Houseowner`='%s'", name);
    mysql_real_escape_string(str, string1);
    mysql_query(string1);
    mysql_store_result();
    mysql_get_field("HouseID", string1); //Gets the first field of the row returned (HouseID)
    mysql_free_result();
    if(!sscanf(str, "d", integer))
    {
        if(integer != 0) //Player has a house...
        {
            format(string, sizeof(string), "SELECT * FROM `Vehicles` WHERE `HouseID`= '%d'", integer);
            mysql_query(string);
            if(mysql_num_rows() != 0)
            {
                while(mysql_num_rows()) //Loop xD
                {
                    //Do what you want with the vehicle :P
                    //Use db_get_field or db_get_field_assoc
                    //Remember to store the vehicle IDs in a variable so you can delete them in OnPlayerDisconnect
                    mysql_get_field("Model", cModel);
                    mysql_get_field("X", cx);
                    mysql_get_field("Y", cy);
                    mysql_get_field("Z", cz);
                    mysql_get_field("Rot", crot);
                    mysql_get_field("Color1", Col1);
                    mysql_get_field("Color2", Col2);
                    new hId = strval(str);
                    House_AddVehicle(hId, strval(cModel), floatstr(cx), floatstr(cy), floatstr(cz), floatstr(crot), strval(Col1), strval(Col2));
                    print("Car loaded");
                }
                print("Does work");
            }

        }
    }
Where this part goes wrong:

pawn Код:
format(str, sizeof(str), "SELECT `HouseID` FROM `Houses` WHERE `Houseowner`='%s'", name);
    mysql_real_escape_string(str, string1);
    mysql_query(string1);
    mysql_store_result();
    mysql_get_field("HouseID", string1); //Gets the first field of the row returned (HouseID)
    mysql_free_result();
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)