This topic is locked

Max value in Before Record added

10/19/2010 7:34:50 AM
PHPRunner General questions
S
sickacid author

Hi support!

I want to check the data entered in form with those in the table before they are written.

My idea was to control if the value is less of 500 km than previously inserted in the table.

I think we must look in the table the maximum value for a given vehicle (idTarga).

KmFine is the field from table tabelladischetti where we insert the final kilometers of every day,

for every vehicle (idTarga)

In this code there is many error ... =) =)
Can anyhone help me?
//data from table

global $conn;

$id = $values["IdTarga"];

$str = "select * KmFine from tabelladischetti where Id='".$id."'";

$rs = db_query($str,$conn);

$data = db_fetch_array($rs);

$KmFine = $data["KmFine"];
//data from form

$KmControllo = $values["KmFine"];
//control point

if (($KmControllo - $KmFine) < 500)

{

return true;

}

else

{

$message = "<div class=message>NON PUOI INSERIRE IL DISCHETTO PERCHè NON è CORERENTE CON IL PRECEDENTE!!!</div>";

return false;

}

Sergey Kornilov admin 10/19/2010

You need to be more specific. What exactly errors are and which line of code causes the error?
You can also 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.

S
sickacid author 10/25/2010

i get this error...
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'KmFine from tabelladischetti where Id='28'' at line 1

A
ann 10/25/2010

Simone,
you have syntax error in the following line:

$str = "select * KmFine from tabelladischetti where Id='".$id."'";



There is no need to use single quotes for the numerical field.

Here is the correct line:

$str = "select * KmFine from tabelladischetti where Id=".$id;
S
sickacid author 10/25/2010

no... anyway i get the error..
this is the code..
IdTarga is id of veichles

Kmfine is the field that contains the number of end_Kilometers in the day before, i've to extract the max value of this field to

compare with the new insertion, if the value is <500 do something, else do...

but it don't works.. <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=53885&image=1&table=forumreplies' class='bbc_emoticon' alt=':(' />(
//data from table - get existing data from table

global $conn;

$id = $values["IdTarga"];

$str = "select * KmFine from tabelladischetti where Id=".$id."";

$rs = db_query($str,$conn);

$data = db_fetch_array($rs);

$KmFine = $data["KmFine"];

db_exec($str,$conn);
//data from Form

$KmControllo = $values["KmFine"];
//control point

if (($KmControllo - $KmFine) < 500)

{

return true;

}

else

{

$message = "<div class=message>NON PUOI INSERIRE IL DISCHETTO PERCHè NON è CORERENTE CON IL PRECEDENTE!!!</div>";

return false;

}

Sergey Kornilov admin 10/25/2010

I recommend 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.