Jump to content

Recommended Posts

Just for future reference, posting "it doesn't work" without explaining in what way it doesn't work doesn't help us help you. Is $guestno an integer value. By that, I mean it is a int, not string, even if the string holds a numeric value.

 

You may want is_numeric? Or you can just use intval to cast it as an integer.

sorry for cutting the details, by it doesnt work, i mean for both "1" and "1a" the result is false.

Thanks

Just to add on, i don't want intval(), i just want to check if the value is interger or not, and i replaced is_int() with is_numeric, it worked, but i have no clue why is_int doesn't work, i strongly believe it's a bug.

string(1) "1", i guess u are right, then what should I use in this situation to test out if the input value is an integer?

<form name="addorder" action="" method="post">
<input name="guestno" value="<?php echo $guestno;?>" type="text" size="30" maxlength="2" /><br />
<?php if (isset($_POST['submit'])){
$guestno = $_POST['guestno'];
if (!is_int($guestno)) 
{echo "<p><b>Guest number field must be in integers!<b></p>"; $invalid = true;}?>

Thanks.

$_POST values are always strings, just so you know.

 

And have you read a thing I said in my first 2 posts. Here's intval

$guestno = intval($_POST['guestno']);

ive read the manual about intval, it does fix the string to make it an integer, but it doesn't check if the input is an integer, that's what i don't like about the function. is there a way to check instead of changing?

Thanks again

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.