php(POST) - mysql - integer

php(POST) - mysql - integer

am 21.08.2007 23:05:56 von Claudio Lanzi

Hi,

I want to do a mysql query and need an int for this but i get the value as
string, so i tried this:
      if ($_POST['seminar']!="") //seminar defined?
        {
        $seminar=$_POST['seminar']; //get seminar from post
        $attending=$_POST['attending']; // get attending from post
        // convert string to int
        if ($attending=="1")
          $INTatt==1;
        elseif ($attending=="2")
          $INTatt==2;
        elseif ($attending=="3")
          $INTatt==3;
        else
          {// print error
          echo "invalid number of attending members! - ERROR!";
          exit(0);
          }
        // is this really an int?
        if (is_int($INTatt))
        echo "int";
        $query="UPDATE seminar SET taken = taken+".$INTatt." where
`time-date`
= '".$seminar."'";
        mysql_query($query);
        }
It doesn't print "int" as it should when going thru is_int(). Why is this
variable $INTatt no int? I don't get it... is there another possibility of
realizing this? the field taken is an int in the db (apparently).
Thanks for every help!
Ron

Re: php(POST) - mysql - integer

am 21.08.2007 23:30:12 von Martin Zemke

Ron Eggler schrieb:
> Hi,
>
> I want to do a mysql query and need an int for this but i get the value as
> string, so i tried this:
> if ($_POST['seminar']!="") //seminar defined?
> {
> $seminar=$_POST['seminar']; //get seminar from post
> $attending=$_POST['attending']; // get attending from post
> // convert string to int
> if ($attending=="1")
> $INTatt==1;
> elseif ($attending=="2")
> $INTatt==2;
> elseif ($attending=="3")
> $INTatt==3;
> else
> {// print error
> echo "invalid number of attending members! - ERROR!";
> exit(0);
> }
> // is this really an int?
> if (is_int($INTatt))
> echo "int";
> $query="UPDATE seminar SET taken = taken+".$INTatt." where
> `time-date`
> = '".$seminar."'";
> mysql_query($query);
> }
> It doesn't print "int" as it should when going thru is_int(). Why is this
> variable $INTatt no int? I don't get it... is there another possibility of
> realizing this? the field taken is an int in the db (apparently).
> Thanks for every help!
> Ron

$INTatt==1;
There is the mistake. Try $INTatt=1;

== -> comparison
= -> allocation