Using Floats in MySQL
#1

Hello,

My question is simple: How can I use floats in a MySQL column? I set 'type' to 'float' but then it uses comma's, while I need dots as float seperator. Decimal is not working.

Jochem
Reply
#2

erm using "FLOAT" works fine.. can you make a table dump?
Reply
#3

Just use VARCHAR if you're unsure.
Reply
#4

Worked out in the program, I think it also does in the script. Thanks!

Quote:
Originally Posted by Donya
Посмотреть сообщение
erm using "FLOAT" works fine.. can you make a table dump?
No idea what you're talking about. I am not long in MySQL yet.
Reply
#5

Quote:
Originally Posted by Jochemd
Посмотреть сообщение
Worked out in the program, I think it also does in the script. Thanks!


No idea what you're talking about. I am not long in MySQL yet.
He talking about sql table in phpmyadmin
Reply
#6

Oh, I don't use that

Btw, now I get this, in my mysql_log.txt

Код:
>> mysql_num_rows() - Invalid connection handle. (You set: 0, Highest connection handle ID is 0).
Same with 1

Код:
>> mysql_num_rows() - Invalid connection handle. (You set: 1, Highest connection handle ID is 0).
Reply
#7

Can you show you'r script where you using mysql_num_rows?
Reply
#8

Of course

Piece out OnGameModeInit

pawn Код:
for(new v = 0; v < MAX_VEHICLES; v ++)
    {
        new QueryString[128],Line[128],ID,modelid,VehicleColor,Own[MAX_PLAYER_NAME],Float:VehicleAngle,doors,panels,lights,tires,Float:Health,VehiclePos[3],Fuel2,ParkedLot2,PhoneBooks2,Ropes2,BlindFolds2,MedicalKits2;
        VehicleInfo[v][Fuel] = 100;
        format(QueryString,sizeof(QueryString),"SELECT * FROM `VehicleInfo` WHERE `ID` = '%d'",v);
        mysql_query(QueryString);
        mysql_store_result(0);
        if(mysql_num_rows(0) != 0)
        {
            if(mysql_fetch_row(Line))
            {
                sscanf(Line,"p<>dds[24]ffffdddddfddddd",ID,modelid,VehicleColor,Own,VehiclePos[0],VehiclePos[1],VehiclePos[2],VehicleAngle,Fuel2,doors,panels,lights,tires,Health,ParkedLot2,PhoneBooks2,Ropes2,BlindFolds2,MedicalKits2);
                new vehicleid = CreateVehicle(modelid,VehiclePos[0],VehiclePos[1],VehiclePos[2],VehicleAngle,VehicleColor,VehicleColor,-1);
                VehicleInfo[vehicleid][FileVehicleID] = v;
                VehicleInfo[vehicleid][Owned] = 1;
                VehicleInfo[vehicleid][Fuel] = Fuel2;
                VehicleInfo[vehicleid][ParkedLot] = ParkedLot2;
                VehicleInfo[vehicleid][ContainingPhonebooks] = PhoneBooks2;
                VehicleInfo[vehicleid][ContainingRopes] = Ropes2;
                VehicleInfo[vehicleid][ContainingBlindfolds] = BlindFolds2;
                VehicleInfo[vehicleid][ContainingMedicalKits] = MedicalKits2;
                format(VehicleInfo[vehicleid][Owner],MAX_PLAYER_NAME,"%s",Own);
                SetVehicleHealth(vehicleid,Health);
                OnVehicleDamageStatusUpdate(vehicleid,-1);
                UpdateVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
                printf("Owner File Vehicle ID '%d' (vehicleid '%d') has been created at X:%.3f || Y:%.3f || Z:%.3f",v,vehicleid,VehiclePos[0],VehiclePos[1],VehiclePos[2]);
            }
        }
    }
Reply
#9

That error is triggered if you don't connect to a MySQL server at all.
Reply
#10

Bad usage if(mysql_num_rows(0) != 0)

It should be:
pawn Код:
if(mysql_num_rows() != 0)
But for me looks better:
pawn Код:
if( mysql_num_rows( ))
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)