This topic is locked
[SOLVED]

 Before Record Added - Return False

9/3/2014 8:17:05 AM
PHPRunner General questions
P
prattster1874 author

I have a "before record added" event to check if a number is lower than a number already in the database, if it is lower then I don't want the record added. This works to a degree but it wont let me amend the value and continue. When I "Return False" it just stops doing anything and I can't add a record without refreshing and re-entering all values.

global $conn;
$sql="SELECT mileage from tbl_vehicle where reg_number='".$values["vehicle_id"]."'";

$rsExists = db_query($sql,$conn);

$data=db_fetch_array($rsExists);
if($data["mileage"]<$values['mileage'])

{

$message="Mileage lower than last recorded -".$data["mileage"].">".$values['mileage'];

return false;



}
$values['logged_date']=now();

$values['active']=1;

$values['vehicle_status']=0;

// Place event code here.

// Use "Add Action" button to add code snippets.

$values['active']='1';

$values['attention_flag']=1;

$values['supplier_id']=$_SESSION['company_id'];

$values['depot_id']=$_SESSION['depot_id'];

$values['authorisation_status']=3;

$values['supplier_accept']=1;
return true;
Sergey Kornilov admin 9/3/2014

It looks like you doing it right. Unfortunately there is not enough info to provide a meaningful advise. If you need more help post your application to Demo Account and open a ticket at http://support.xlinesoft.com sending your Demo Account URL. 'Demo Account' button can be found on the last screen in the program.

P
prattster1874 author 9/4/2014



It looks like you doing it right. Unfortunately there is not enough info to provide a meaningful advise. If you need more help post your application to Demo Account and open a ticket at http://support.xlinesoft.com sending your Demo Account URL. 'Demo Account' button can be found on the last screen in the program.


I solved it, it was a data type error. I changed the values both to integers and the comparison worked.
Thanks!