You are here: Re: [PHP] Str to Int « PHP « IT news, forums, messages
Re: [PHP] Str to Int

Posted by "Ron Eggler (Paykiosks)" on 01/21/06 01:19

Am Freitag, den 20.01.2006, 16:08 -0700 schrieb Gerry Danen:
> You probably want to do an is_int() first...
>
> After that, you know it's an int and treat it that way. Why do you
> need to typecast it?
>
> BTW, change $cardID = $HTTP_GET_VARS[cardID]; to $cardID =
> $_GET['cardID']; for PHP5 compatibility... ;-)
>
> Gerry
Hey, it seems to be recognied by is_int() as integer. I have following
code:
[php]
if ($HTTP_GET_VARS) // if some GET variables were passed on,...
{
switch ($HTTP_GET_VARS['action'])// recognize the get-var 'action'
{
case reserve: // it says, 'reserve PINs'
$cardID = $HTTP_GET_VARS['cardID']; // get cardID which was passed by GET as well
if ($cardID=''||is_int($cardID)) // unless,
{
$cardID = intval($cardID.trim());
echo "<b>ERROR, cardID='' or cardID is no integer!</b><br>\n"; //print Error
exit(0); //and leave
}
echo "reserve<br>\n"; // Variables were okay, so go ahead with the reserving
/**************** [reserve SKU] ****************/
$inputdata = '<xs:request xmlns:xs=\'urn:pinXpressSchema\' version=\'1.5\' langCode=\'en\'>'.$n.'
<DEALERinfo aspName="'.$aspName.'"
dealerName="'.$dealerName.'"
posName="'.$posName.'"
posPassword="'.$posPassword.'"
userName="'.$userName.'"
userPassword="'.$userPassword.'"/>
<reservePINs>
<getPIN cardID="'.intval(trim($cardID)).'" quantity="1" />
</reservePINs>
</xs:request>';
/**************** [/reserve SKU] ***************/
break;
[/php]

it doesn't work that way but if I replace ['.intval(trim($cardID)).']
with [180] (everything between the []-brakets) it seems to work and
cardID was passed with the URL:
http://localhost/ewi.php?action=reserve&cardID=180
So what the hell is going wrong?
Thank you!

chEErs roN

>
> On 1/20/06, Ron Eggler (Paykiosks) <ron@paykiosks.net> wrote:
> Hi,
>
> I need to do a type cast from string to int in folllowing
> code:
> [php]
> <getPIN cardID="'.intval(trim($cardID)).'" quantity="1" />
> [/php]
> I need $cardID have converted to int. I thought it should work
> that way
> but it does not!
> But it's working if I'm putting
> [php]
> <getPIN cardID="180" quantity="1" />
> [/php]
> in there. I got card ID as a var that is passed as get like:
> [php]
> $cardID = $HTTP_GET_VARS[cardID];
> [/php]
>
> Can anyone help me in that issue? Thank you!
>
> __________________________________________
>
> Ron Eggler
> Intern
> 866-999-4179
> www.paykiosks.net
>
>
>
>
>
>
> --
> Gerry
> http://portal.danen.org/

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация