ginginca 0 Report post Posted November 20, 2006 (edited) I put together this: //Make Sure $qty is NOT blank before checking if it is a number if (!empty($item_1_qty)) {//not empty } if (intval($item_1_qty) !== $item_1_qty){ //item 1 qty is not a whole number $redirect_to = 'order_form.php?error=6'; header("Location: $redirect_to"); exit(); } But I get my error message coming no matter whether it is an integer or not. Edited November 20, 2006 by ginginca (see edit history) Share this post Link to post Share on other sites
iGuest 3 Report post Posted November 20, 2006 if (intval($item_1_qty) !== $item_1_qty){Where is the value for the $item_1_qty coming from? if it is coming from a form, it may be cast as a string and the php.net site lists a series of examples which you might be interested in reviewing.http://us3.php.net/manual/en/function.intval.php Share this post Link to post Share on other sites
TavoxPeru 0 Report post Posted November 20, 2006 I put together this: //Make Sure $qty is NOT blank before checking if it is a number if (!empty($item_1_qty)) {//not empty } if (intval($item_1_qty) !== $item_1_qty){ //item 1 qty is not a whole number $redirect_to = 'order_form.php?error=6'; header("Location: $redirect_to"); exit(); } But I get my error message coming no matter whether it is an integer or not.If your variable is coming from a form i reccomend you to cast it before you use it, its simple:$item_1_qty = (int) $_POST['item_1_qty'];Also take a look to the is_numeric() php function, because it is recommended to use it with variables that are submited by a form.Best regards, Share this post Link to post Share on other sites
Hercco 0 Report post Posted November 23, 2006 PHP has a function called is_int() to test if parameter is integer. Why not just use that? Share this post Link to post Share on other sites
Quatrux 4 Report post Posted November 23, 2006 ..and why not better to use a function is_numeric() to see if the variable is a number or a numeric string, or you really need it to be integer.. But if so, the above replies have said enough. Share this post Link to post Share on other sites