This topic is locked
[SOLVED]

 Check number with point or comma

2/3/2011 6:38:44 AM
PHPRunner General questions
S
sickacid author

Hi in the add page, before record added, i use this code to prevent users insert records double,

but if I inserted a number with a comma instead of a point,the control jumps. How can i do?

The values to check is Litri.
global $conn;

$DA = $values["Data"];

$TA = $values["IdTarga"];

$LI = $values["Litri"];
$strSQLExists = "select * from tabellaspese where Data='".$DA."' and IdTarga='".$TA."' and Litri='".$LI."'";

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

$data=db_fetch_array($rsExists);

if($data)

{

$message = "<div class=message>DOCUMENTO GIA' INSERITO!!</div>";

return false;

}

else

{

--rbegin--// if dont exist do something else--rend--

$values["LastUser"]=$_SESSION["UserID"];

}

return true;

S
sickacid author 2/4/2011

$LI = str_replace(",", ".", $LI);
Works!