Using Random number as a percentage
Posted: Fri Mar 25, 2011 7:30 am
Firstly,
I am trying to generate a random number between two known number.
My script grabs an aircraft type from a database and i am trying to use the IF command like so.
Obviously i am not using the Random function correctly as it spits out all sorts of numbers.
Secondly,
I have an active database table called pireps. it has a column "load"
my test table is called test (duh) and also has a column "load"
both have the same attributes ie type, length/values etc.
When i try to do an INSERT using a column "load" and variable "tload" i get a syntax error.
if instead of using load and tload i rename them pass and tpass (creating a column "pass" in my table with exactly the same attributes and renaming my field "load" to "pass") it works fine.
I need to update the column "load" as i cannot change it.
Anyone any ideas why this might be the case
here is the insert using "pass"
heres the error message i get when changed to load

message
It has me baffled!!!
I am trying to generate a random number between two known number.
My script grabs an aircraft type from a database and i am trying to use the IF command like so.
Code: Select all
--generate the passenger numbers for each aircraft type trying to generate random passenger count (approx 80% capacity) for each type of aircraft
put "SELECT name from phpvms_aircraft where id='"&tAircraft&"'"into tplane
put revDataFromQuery(comma,return,gConnectionID,tplane) into tplanedata
if tplanedata is"B737-300" then
put random(140) +60 into tpass -- max passengers = 180
else if tplanedata is "FOKKER50" then
put random (58) +10 into tpass --max passengers = 58
else if tplanedata is "B777-200" then
put random (440)+300 into tpass -- max passengers = 440
else if tplanedata is "IL96" then
put random(90000) +10000 into tpass -- this is lbs of cargo
else if tplanedata is "MD81" then
put random(140) +40 into tpass -- max passengers = 157
Secondly,
I have an active database table called pireps. it has a column "load"
my test table is called test (duh) and also has a column "load"
both have the same attributes ie type, length/values etc.
When i try to do an INSERT using a column "load" and variable "tload" i get a syntax error.
if instead of using load and tload i rename them pass and tpass (creating a column "pass" in my table with exactly the same attributes and renaming my field "load" to "pass") it works fine.
I need to update the column "load" as i cannot change it.
Anyone any ideas why this might be the case
here is the insert using "pass"
Code: Select all
INSERT INTO phpvms_test (pilotid,code,aircraft,flightnum,depicao,arricao,flighttime,flighttime_stamp,distance,submitdate,fuelused,fuelunitcost,fuelprice,flighttype,gross,pilotpay,revenue,pass,price,rawdata) VALUES ('081','AVA','8 ','302A','KLAX','CYUL','03:36','3:36 AM','376.443','2011,3,25,6,0,0,6','2301','0.96','2209','P','254100','360.72','251530.32','605','420','first pirep')

message
Code: Select all
INSERT INTO phpvms_test (pilotid,code,aircraft,flightnum,depicao,arricao,flighttime,flighttime_stamp,distance,submitdate,fuelused,fuelunitcost,fuelprice,flighttype,gross,pilotpay,revenue,load,price,rawdata) VALUES ('081','AVA','8 ','302A','KLAX','CYUL','03:36','3:36 AM','376.443','2011,3,25,6,21,0,6','2301','0.96','2209','P','186060','360.72','183490.32','443','420','first pirep')