php(POST) - mysql - integer

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! - <b>ERROR</b>!";
          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
Claudio Lanzi [ Di, 21 August 2007 23:05 ] [ ID #1801147 ]

Re: php(POST) - mysql - integer

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! - <b>ERROR</b>!";
> 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
Martin Zemke [ Di, 21 August 2007 23:30 ] [ ID #1801148 ]
Datenbanken » de.comp.datenbanken.mysql » php(POST) - mysql - integer

Vorheriges Thema: MySQL Ausgabe optimieren
Nächstes Thema: left join, aber wie?