Announcement

Collapse
No announcement yet.

integer

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • integer

    I have a form input that is going into a mysql DB. Is there a function that I could use to check that the contents of the variable is an integer?

    Cheers.

    Rob - Wellington College

  • #2
    PHP Code:
    if (intval($variable)) {
        
    // blah blah blah;

    Something like that...it can't be plain is_int because form data is automatically a string, I think...i could be wrong
    Last edited by Dan615; Fri 13 Sep '02, 11:49am.

    Comment


    • #3
      You'll get a false negative if the string is '0'.

      To resolve that, change intval() to is_numeric(). PHP 4 required.
      Cygwin - all the tools to make Windows complete (cvs, vim, diff, grep, gcc, ssh, ...)

      Comment


      • #4
        or just use regular typecasting
        (int)$variable
        My open eyes see everything, and you see nothing. . .
        That forum

        Comment

        widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
        Working...
        X