PHP - Is_int Useage
this does not work for me...
Code: [Select] $category=mysql_real_escape_string($_GET['category']); if (is_int($category)) { i echo out $category and confirm it is an integer and yet the if statement does not fire what am i missing? Similar TutorialsHi, I'm a newbie here, and with PHP, and need some help with the datetime display. I am wanting to utilize old Naval comms DTG (datetimegroup) format which is DDHHMM 3-digit Month 2-digit year. The DDHHMM = Day (01 - 31) HH (hour 01 - 24) MM (minute 00 - 59) What I need to do is to add the letter Z (meaning GMT, ZULU) like thus DDHHMMZ FEB 11 How can I go about inserting that Z into this? Tks in advance for any assist Hi, I did a search for this function and found a similar post but wasn't able to understand it. Presently I am just trying to do a simple test with the is_int function. I have it set up as follows: Code: [Select] if (is_int ($variable)) { echo 'Integer'; } else { echo 'Not integer'; $variable is converted to a variable from some text on a web form. I can see the problem here is that no matter what is entered on the web form, $variable is always a string. The code I referenced above works fine if I instead use the is_string function. I guess I'm just trying to figure out the following: 1. Why is it always a string, even when entering a number such as 7? 2. How can I overcome this so that I can check to make sure the input is of the correct type (integer)? I know I'm probably not doing a good job of explaining what I mean but I think what I'm aiming to do should be clear; let me know if it isn't. NOTE--I think I get this to a degree--anything passed in a form will be a string, is that correct? So I should be able to use is_numeric instead. However, the problem with that is that it would also return True for non-integers such as floats. I only want the user to be able to enter integers, 8.5 should return False in this case. Thanks! $showCountSql = "select cad_count from counteraccountdtl WHERE cad_userid =".$_SESSION['UID']." LIMIT 1"; $showCountresult = mysql_query($showCountSql); $showCountrow = mysql_fetch_array($showCountresult); $newCount = $showCountrow[cad_count]; if(is_int($newCount)) echo "Value is Integer"; else echo "Value not Integer"; i m fetching value by Mysql "cad_count integer(5)" and feild then i cheak this value is interger or not it show the "Value not Integer". What is wrong in it ??? |