Sscanf not assinging values correctly
#4

I have the same problem, but my query is a lot smaller.
pawn Code:
stock LoadVehicles()
{
    new Query[256], count;
    for(new i; i < MAX_VEHICLES; i++)
    {
        format(Query, sizeof(Query), "SELECT * From Vehicles WHERE ID = %d", i);
        print(Query);
        mysql_query(Query);
        mysql_store_result();
        if(mysql_num_rows())
        if(mysql_fetch_row_format(Query, "|"))
        {
            sscanf(Query, "iiffff", vData[i][vehID], vData[i][vehModel], vData[i][XPos], vData[i][YPos], vData[i][ZPos], vData[i][Angle]);
            CreateVehicle(vData[i][vehModel], vData[i][XPos], vData[i][YPos], vData[i][ZPos], vData[i][Angle], random(126), random(126), 60);
            printf("%d %d %f %f %f %f", vData[vehID], vData[i][vehModel], vData[i][XPos], vData[i][YPos], vData[i][ZPos], vData[i][Angle]);
            mysql_free_result();
            count ++;
        }
    }
    printf("%d vehicles were loaded from the database. ", count);
}
Console says this:
Quote:

[13:59:11] SELECT * From Vehicles WHERE ID = 1
[13:59:11] 0 0 0.000000 0.000000 0.000000 0.000000
[13:59:11] SELECT * From Vehicles WHERE ID = 2
[13:59:11] 0 0 0.000000 0.000000 0.000000 0.000000
[13:59:11] SELECT * From Vehicles WHERE ID = 3
[13:59:11] 0 0 0.000000 0.000000 0.000000 0.000000
[13:59:11] SELECT * From Vehicles WHERE ID = 4
[13:59:11] 0 0 0.000000 0.000000 0.000000 0.000000

While mysql_debug tells me this:
Quote:

[14:06:30] CMySQLHandler::Query(SELECT * From Vehicles WHERE ID = 1) - Successfully executed.
[14:06:30] >> mysql_store_result( Connection handle: 1 )
[14:06:30] CMySQLHandler::StoreResult() - Result was stored.
[14:06:30] >> mysql_num_rows( Connection handle: 1 )
[14:06:30] CMySQLHandler::NumRows() - Returned 1 row(s)
[14:06:30] >> mysql_fetch_row_format( Connection handle: 1 )
[14:06:30] CMySQLHandler::FetchRow() - Return: 1|411|4.64056|6.1187|2.86991|52.5
[14:06:30] >> mysql_free_result( Connection handle: 1 )
[14:06:30] CMySQLHandler::FreeResult() - Result was successfully free'd.
[14:06:30] >> mysql_query( Connection handle: 1 )
[14:06:30] CMySQLHandler::Query(SELECT * From Vehicles WHERE ID = 2) - Successfully executed.
[14:06:30] >> mysql_store_result( Connection handle: 1 )
[14:06:30] CMySQLHandler::StoreResult() - Result was stored.
[14:06:30] >> mysql_num_rows( Connection handle: 1 )
[14:06:30] CMySQLHandler::NumRows() - Returned 1 row(s)
[14:06:30] >> mysql_fetch_row_format( Connection handle: 1 )
[14:06:30] CMySQLHandler::FetchRow() - Return: 2|411|8.7544|2.96196|2.8367|52.4999
[14:06:30] >> mysql_free_result( Connection handle: 1 )
[14:06:30] CMySQLHandler::FreeResult() - Result was successfully free'd.
[14:06:30] >> mysql_query( Connection handle: 1 )
[14:06:30] CMySQLHandler::Query(SELECT * From Vehicles WHERE ID = 3) - Successfully executed.
[14:06:30] >> mysql_store_result( Connection handle: 1 )
[14:06:30] CMySQLHandler::StoreResult() - Result was stored.
[14:06:30] >> mysql_num_rows( Connection handle: 1 )
[14:06:30] CMySQLHandler::NumRows() - Returned 1 row(s)
[14:06:30] >> mysql_fetch_row_format( Connection handle: 1 )
[14:06:30] CMySQLHandler::FetchRow() - Return: 3|411|15.1183|-1.9213|2.84453|52.5
[14:06:30] >> mysql_free_result( Connection handle: 1 )
[14:06:30] CMySQLHandler::FreeResult() - Result was successfully free'd.
[14:06:30] >> mysql_query( Connection handle: 1 )
[14:06:30] CMySQLHandler::Query(SELECT * From Vehicles WHERE ID = 4) - Successfully executed.
[14:06:30] >> mysql_store_result( Connection handle: 1 )
[14:06:30] CMySQLHandler::StoreResult() - Result was stored.
[14:06:30] >> mysql_num_rows( Connection handle: 1 )
[14:06:30] CMySQLHandler::NumRows() - Returned 1 row(s)
[14:06:30] >> mysql_fetch_row_format( Connection handle: 1 )
[14:06:30] CMySQLHandler::FetchRow() - Return: 4|411|23.3501|-8.2377|2.84427|52.4999
[14:06:30] >> mysql_free_result( Connection handle: 1 )
[14:06:30] CMySQLHandler::FreeResult() - Result was successfully free'd.

Reply


Messages In This Thread
Sscanf not assinging values correctly - by Jstylezzz - 03.02.2013, 10:51
Re: Sscanf not assinging values correctly - by Jstylezzz - 04.02.2013, 13:27
Re: Sscanf not assinging values correctly - by Jstylezzz - 04.02.2013, 14:42
Re: Sscanf not assinging values correctly - by spedico - 05.02.2013, 10:43
Re: Sscanf not assinging values correctly - by spedico - 05.02.2013, 11:00
Re: Sscanf not assinging values correctly - by spedico - 05.02.2013, 12:07
Re: Sscanf not assinging values correctly - by Jstylezzz - 05.02.2013, 12:14
Re: Sscanf not assinging values correctly - by Jstylezzz - 05.02.2013, 12:33
Re: Sscanf not assinging values correctly - by Jstylezzz - 05.02.2013, 12:41
Re: Sscanf not assinging values correctly - by Jstylezzz - 05.02.2013, 12:48
Re: Sscanf not assinging values correctly - by Jstylezzz - 06.02.2013, 12:34
Re: Sscanf not assinging values correctly - by Jstylezzz - 06.02.2013, 13:02

Forum Jump:


Users browsing this thread: 2 Guest(s)