[PHP] comparing a string

2006-06-20 Thread Ross
I have a quiz where the ansers are held in a array called $correct answers. When I compare the string if ($_REQUEST['x']= $correct_answers[$page-1]) { with a double == the answer is always correct with the single = it is always wrong. when I echo out the posted answer and the value from

Re: [PHP] comparing a string

2006-06-20 Thread Larry Garfield
= is the assignment operator. It is not a comparison. == is the weak equality comparator. === is the strong equality comparator. On Tuesday 20 June 2006 06:43, Ross wrote: I have a quiz where the ansers are held in a array called $correct answers. When I compare the string if

Re: [PHP] comparing a string

2006-06-20 Thread tedd
At 12:43 PM +0100 6/20/06, Ross wrote: I have a quiz where the ansers are held in a array called $correct answers. When I compare the string if ($_REQUEST['x']= $correct_answers[$page-1]) { with a double == the answer is always correct with the single = it is always wrong. when I echo out

RE: [PHP] comparing a string

2006-06-20 Thread yangshiqi1089
When the $_REQUEST['x'] is not 0 or '', it will be always correct condition of your if. see the magic*. -Original Message- From: tedd [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 20, 2006 10:02 PM To: Ross; php-general@lists.php.net Subject: Re: [PHP] comparing a string At 12:43 PM

Re: [PHP] Comparing of string

2006-01-04 Thread janbro
Hi Jeremy, I tried if ( strcmp( trim($SollKombination), trim($formCheck) ) ) same negativ result. For some reason both strings are not considered to be the same. They have the same length, are of the same type and have the same content. Why PHP doesn't recognize them as beeing equal I don't

Re: [PHP] Comparing of string

2006-01-04 Thread Jeremy Privett
janbro wrote: Hi Jeremy, I tried if ( strcmp( trim($SollKombination), trim($formCheck) ) ) same negativ result. For some reason both strings are not considered to be the same. They have the same length, are of the same type and have the same content. Why PHP doesn't recognize them as beeing

Re: [PHP] Comparing of string

2006-01-04 Thread Raz
I would guess that the '' in $_GET['formCheck'] will cause problems... Trying your code without the ampersand as in: $_GET['formCheck'] = 'ZL0X~TT4PQ%0~R0OXPRUHY7E!4~W337J71V4WDDI6$GS9480XP0TNP2I$1YX75S' It works just fine. -- PHP General Mailing List (http://www.php.net/) To unsubscribe,

[PHP] Comparing of string

2006-01-03 Thread janbro
Hello List I've got the following little code: $formCheck= $_GET['formCheck']; $SollKombination = $_SESSION['zufall']; echo $SollKombinationbr$formCheck; print gettype($formCheck);

Re: [PHP] Comparing of string

2006-01-03 Thread Jon Westcot
Message - From: janbro [EMAIL PROTECTED] To: php-general@lists.php.net Sent: Tuesday, January 03, 2006 11:22 PM Subject: [PHP] Comparing of string Hello List I've got the following little code: $formCheck= $_GET['formCheck']; $SollKombination

Re: [PHP] Comparing of string

2006-01-03 Thread janbro
this helps. Jon - Original Message - From: janbro [EMAIL PROTECTED] To: php-general@lists.php.net Sent: Tuesday, January 03, 2006 11:22 PM Subject: [PHP] Comparing of string Hello List I've got the following little code: $formCheck= $_GET

Re: [PHP] Comparing of string

2006-01-03 Thread Jeremy Privett
janbro wrote: Hello List I've got the following little code: $formCheck= $_GET['formCheck']; $SollKombination = $_SESSION['zufall']; echo $SollKombinationbr$formCheck; print gettype($formCheck);