Re: need code snippet to verify input strings



"Janwillem Borleffs" <jw@xxxxxxxxxxxxx> wrote in news:451ad4ab$0$20623
$dbd4d001@xxxxxxxxxxxxxxx:

http://www.php.net/manual/en/function.is-numeric.php

Okay, that's a good resource, and a good start. But when testing
various values, I get the output :

value of x is:1
value of id is:222
value of id is:


where I would expect x and the second id to be 0, not blank. The test,
when it succeeds, displays 1, but when it fails, it displays nothing.
Test :

$testamt = $_POST["amount"];
$x = is_numeric($testamt);
echo "</br>";
echo "value of x is:";
echo $x;

$id = (int) $_POST["amount"];
echo "</br>";
echo "value of id is:";
echo $id;

$id = is_numeric($_POST["date"]);
echo "</br>";
echo "value of id is:";
echo $id;

Date is obviously not numeric, in that it contains the "/" character.

Any thoughts?

Mairhtin

P.S. if you see something OBVIOUS, please be gentle, I'm a newbie!!!
.



Relevant Pages

  • Re: select count queries
    ... You cannot just echo it. ... > Resource id #x But how does it translate correctly to the actual valuess? ... Good luck Wendy. ... Erwin Moller ...
    (comp.lang.php)
  • Re: fetch_array()
    ... No, it returns a resource, as you have found out. ... require may just be one thing, but a query can return many rows and ... echo $row; ... Geoff Berrow ...
    (comp.lang.php)
  • Re: fetch_array()
    ... No, it returns a resource, as you have found out. ... require may just be one thing, but a query can return many rows and ... echo $row; ... there's no need for the indexed elements. ...
    (comp.lang.php)
  • Re: fetch_array()
    ... Kimmo Laine wrote: ... No, it returns a resource, as you have found out. ... echo $row; ... there's no need for the indexed elements. ...
    (comp.lang.php)
  • mysql_fetch_array(): supplied argument is not a valid MySQL result resource
    ... supplied argument is not a valid MySQL result ... echo $data; ... And this is my search form where it gets the post variables: ...
    (php.general)