[PHP] Client side fatal PHP error

2001-12-25 Thread jjt

A visitor to my site repeatedly receives a fatal error in one of my scripts.

He is using a Compaq PC with IE 6; Windows 98. He gets this error message:
Call to unsupported or undefined function srtoupper() in on line 82.

Line 82 is a compound IF statement which uses strtoupper(). As best I can
tell, the syntax of the statement is fine:

if (strtoupper(substr($xmbrcode,11,1)) != B 
strtoupper(substr($xmbrcode,11,1)) != P 
srtoupper(substr($xmbrcode,11,1)) != H 
srtoupper(substr($xmbrcode,11,1)) != O) {

And more significantly, no one else is reporting this error; I cannot
reproduce it. The script is executed thousands of times each day. By the
time he gets to line 82, he has successfully passed another simple
strtoupper() statement. Every user running this script must get past line
82.

I am very confused here.  Why does this error occur only on his computer?
How could it be machine or browser dependent? Isn't all PHP processing
done on my host (server) computer? And if so, why does the error not
occur every time the script is executed?

I am totally baffled by this. Can anyone help?

Thanks,

Hershel M. Chicowitz
[EMAIL PROTECTED]





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Client side fatal PHP error

2001-12-25 Thread James Cox

Well, what you have said here isn't that clear, however consider the
following revised code:

$teststr = strtoupper(substr($xmbrcode,11,1));
if(($teststr != B)  ($teststr != P)  ($teststr != H)  ($teststr
!= O)){
do..
}

What you are doing is executing the substr and strtoupper many times, which,
on a slow connection which may have backlog (thus slower time for the html
stream buffer to be delivered), it could timeout.

More detail on a: the error, and b: the code *in context* would help.

Regards,

James Cox

 -Original Message-
 From: jjt [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, December 25, 2001 6:36 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP] Client side fatal PHP error


 A visitor to my site repeatedly receives a fatal error in one of
 my scripts.

 He is using a Compaq PC with IE 6; Windows 98. He gets this error message:
 Call to unsupported or undefined function srtoupper() in on line 82.

 Line 82 is a compound IF statement which uses strtoupper(). As best I can
 tell, the syntax of the statement is fine:

 if (strtoupper(substr($xmbrcode,11,1)) != B 
 strtoupper(substr($xmbrcode,11,1)) != P 
 srtoupper(substr($xmbrcode,11,1)) != H 
 srtoupper(substr($xmbrcode,11,1)) != O) {

 And more significantly, no one else is reporting this error; I cannot
 reproduce it. The script is executed thousands of times each day. By the
 time he gets to line 82, he has successfully passed another simple
 strtoupper() statement. Every user running this script must get past line
 82.

 I am very confused here.  Why does this error occur only on his computer?
 How could it be machine or browser dependent? Isn't all PHP processing
 done on my host (server) computer? And if so, why does the error not
 occur every time the script is executed?

 I am totally baffled by this. Can anyone help?

 Thanks,

 Hershel M. Chicowitz
 [EMAIL PROTECTED]





 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Client side fatal PHP error

2001-12-25 Thread jjt

Thanks for your help. I do not have any more info on the error; that is all
the visitor to my site provided. But I am not sure what more useful detail
there could be; it was a fatal error as I described; the script aborted on
line 82, the IF statement.

However, it might be useful to know that my host computer is running version
3.0.12 of PHP3 on a Unix server.

As for the code, I am not sure what more context would be helpful; the error
message indicated a failure on the function strtoupper() in that statement.
The statement is within a validation routine. I am running a series of tests
on $xmbrcode, a cookie variable; each test is independent.

You are correct in that creating a new variable instead of substringing it 3
times would be more efficient. However I cannot see how this would make a
significant difference.

I am baffled as to why PHP would fail on a valid statement, and fail only
for that user. Since the code is executed on the host computer, I do not see
how a slow connection would have any effect on it. I can see why extremely
heavy traffic on my host computer might cause a timeout, but not for one
user only, and not always on the same statement. By the time the HTML code
is sent to the user, I thought that the execution of PHP was done. In any
event, today, when this error was reported to me, has been one of the
slowest days of the year at my site.

Maybe I just baffle easily

Thanks for your help.

- hmc


James Cox wrote in message ...
Well, what you have said here isn't that clear, however consider the
following revised code:

$teststr = strtoupper(substr($xmbrcode,11,1));
if(($teststr != B)  ($teststr != P)  ($teststr != H)  ($teststr
!= O)){
 do..
}

What you are doing is executing the substr and strtoupper many times,
which,
on a slow connection which may have backlog (thus slower time for the html
stream buffer to be delivered), it could timeout.

More detail on a: the error, and b: the code *in context* would help.

Regards,

James Cox

 -Original Message-
 From: jjt [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, December 25, 2001 6:36 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP] Client side fatal PHP error


 A visitor to my site repeatedly receives a fatal error in one of
 my scripts.

 He is using a Compaq PC with IE 6; Windows 98. He gets this error
message:
 Call to unsupported or undefined function srtoupper() in on line
82.

 Line 82 is a compound IF statement which uses strtoupper(). As best I can
 tell, the syntax of the statement is fine:

 if (strtoupper(substr($xmbrcode,11,1)) != B 
 strtoupper(substr($xmbrcode,11,1)) != P 
 srtoupper(substr($xmbrcode,11,1)) != H 
 srtoupper(substr($xmbrcode,11,1)) != O) {

 And more significantly, no one else is reporting this error; I cannot
 reproduce it. The script is executed thousands of times each day. By the
 time he gets to line 82, he has successfully passed another simple
 strtoupper() statement. Every user running this script must get past line
 82.

 I am very confused here.  Why does this error occur only on his computer?
 How could it be machine or browser dependent? Isn't all PHP processing
 done on my host (server) computer? And if so, why does the error not
 occur every time the script is executed?

 I am totally baffled by this. Can anyone help?

 Thanks,

 Hershel M. Chicowitz
 [EMAIL PROTECTED]





 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Client side fatal PHP error

2001-12-25 Thread Philip Olson

 Call to unsupported or undefined function srtoupper() in on line 82.

srt != str (typo).  

 if (strtoupper(substr($xmbrcode,11,1)) != B 
 strtoupper(substr($xmbrcode,11,1)) != P 
 srtoupper(substr($xmbrcode,11,1)) != H 
 srtoupper(substr($xmbrcode,11,1)) != O) {

See above.  Btw, consider something like:

  $str = '123456789abcdef';
  $bad = array('B','P','H','O');

  if (in_array(strtoupper($str{11}),$bad)) {
  echo 'boo';
  }

I can't believe people code on Christmas :)

Warm regards,
Philip Olson


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Client side fatal PHP error

2001-12-25 Thread LaserJetter

Is there a utility out there that checks for typos, like a spell check but
for code? They are the most annoying things ever and probably the hardest of
errors to find in scrips.
Something simple, even command line would be handy.

Also, its interesting that only one user of the script got the error. What
about all the others? Are they not as considerate as this one guy who
actually reported the problem?


Philip Olson [EMAIL PROTECTED] wrote in message
Pine.BSF.4.10.10112252053030.8996-10@localhost">news:Pine.BSF.4.10.10112252053030.8996-10@localhost...
  Call to unsupported or undefined function srtoupper() in on line
82.

 srt != str (typo).

  if (strtoupper(substr($xmbrcode,11,1)) != B 
  strtoupper(substr($xmbrcode,11,1)) != P 
  srtoupper(substr($xmbrcode,11,1)) != H 
  srtoupper(substr($xmbrcode,11,1)) != O) {

 See above.  Btw, consider something like:

   $str = '123456789abcdef';
   $bad = array('B','P','H','O');

   if (in_array(strtoupper($str{11}),$bad)) {
   echo 'boo';
   }

 I can't believe people code on Christmas :)

 Warm regards,
 Philip Olson






-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Client side fatal PHP error

2001-12-25 Thread James Cox

Yeah,

I know it's executed client side, but if the buffer fills up because you
have a lot to send to the client (and the network connection is saturated),
then it might fail, since it cannot do the test. it is unlikely, but
possible. Also, that code you quoted is (out of context) inefficient, so
that might prove why.

Also, it's worth noting that only 1 in 10 people complain about something.
Thus, your one client reporting this error may mean there are 10 out there
:)

Best bet is to get his headers etc (set up a seperate log site? get him to
dump the page for you as you echo variables and debug info? -- you certainly
won't know which strtoupper it fails on if they are all on the same line :))
Also, get him to give you his cookies -- chances are there could be a
datatype incompatibility.

The bottom line i am getting across here is that there are so many
possibilities here for potential errors, (like in many things) that it is
hard to pinpoint what might be wrong.

If it helps, i am more than happy to look at your code and see if i can
break it.

Regards, and now christmas day is drawing to a close, merry new year :)

James Cox
--
[EMAIL PROTECTED]
Please always Cc to me when replying to me on the lists.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Client side fatal PHP error

2001-12-25 Thread jjt

Ah yes... that would do it. How embarrassing! But another respondent brought
up an interesting question. Why does this error not show up every time? As
written, it is a basic syntactical error. I tested this thing up and down; I
test it in production every day.

Ah it's always something thanks much.


Philip Olson wrote in message ...
 Call to unsupported or undefined function srtoupper() in on line
82.

srt != str (typo).

 if (strtoupper(substr($xmbrcode,11,1)) != B 
 strtoupper(substr($xmbrcode,11,1)) != P 
 srtoupper(substr($xmbrcode,11,1)) != H 
 srtoupper(substr($xmbrcode,11,1)) != O) {

See above.  Btw, consider something like:

  $str = '123456789abcdef';
  $bad = array('B','P','H','O');

  if (in_array(strtoupper($str{11}),$bad)) {
  echo 'boo';
  }

I can't believe people code on Christmas :)

Warm regards,
Philip Olson




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Client side fatal PHP error

2001-12-25 Thread Philip Olson

 Is there a utility out there that checks for typos, like a spell check but
 for code? They are the most annoying things ever and probably the hardest of
 errors to find in scrips.
 Something simple, even command line would be handy.

It's good to program with error_reporting turned all the way up, E_ALL,
which is configured with the error_reporting directive (see php.ini) or by
the error_reporting function:

  error_reporting(E_ALL);

Undefined variables, misspelled function names, and various typos will
most likely turn up an error (unless you find a undocumented feature :).
When an error says undefined function then it's either:

  a) Built-in PHP functions
- A typo
- PHP was not compiled with the given extension.  For example, 
  if mysql_connect is undefined, mysql wasn't compiled into PHP.
  b) User defined
- A typo
- Undefined, as in a function library wasn't includ()ed, etc.

If a variable is undefined, it could be a typo because all good little
programs make sure their variables are defined before use :)  Anyway this
rambling rant basically says turn up error_reporting and use Common Sense.
And, to keep in mind that error reporting isn't perfect.

If an error stumps someone, searching the archives (or google) for the
error can be helpful.  For example:

  http://marc.theaimsgroup.com/?l=php-generals=headers+already+sent
  http://www.google.com/search?q=php+%22headers+already+sent%22

Anyway, what was the question again? :)

Regards,
Philip Olson



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Client side fatal PHP error

2001-12-25 Thread Philip Olson

 Ah yes... that would do it. How embarrassing! But another respondent brought
 up an interesting question. Why does this error not show up every time? As
 written, it is a basic syntactical error. I tested this thing up and down; I
 test it in production every day.

This error will happen every time.  Check your error_reporting setting
*shrugs* See the email I just posted.

 Ah it's always something thanks much.

Yep :)

Regards,
Philip Olson


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Client side fatal PHP error

2001-12-25 Thread Ken

At 08:53 PM 12/25/01 -0500, jjt wrote:
Why does this error not show up every time?

It will show up every time PHP attempts to call the (incorrect) function.  But the 
functions won't be called every time.

For example, due to short-circuit evaluation, if the string is B or P, the error 
will never happen.

Also, if your if statement isn't always reached, then the error will not happen.  
Finally, not all users will report the error when they get it.  But you can deal with 
that by looking at your PHP error log file.

I believe there is a way to call PHP from the command line and do a syntax check on 
a given file.  But I have never tried it and I have no idea if it really works.  Check 
the manual.

- Ken
[EMAIL PROTECTED]

  if (strtoupper(substr($xmbrcode,11,1)) != B 
  strtoupper(substr($xmbrcode,11,1)) != P 
  srtoupper(substr($xmbrcode,11,1)) != H 
  srtoupper(substr($xmbrcode,11,1)) != O) {


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Client side fatal PHP error

2001-12-25 Thread Andrew Brampton

because the way  is evaluated.

if the first part of the  expression is false, then it doesn't even
attempt to look at the second part, meaning you get a fastest evaluation
:)...

I think its called Lazy Logic or something, I know its in the PHP Manual
somewhere :)

Andrew
- Original Message -
From: jjt [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, December 26, 2001 1:53 AM
Subject: Re: [PHP] Client side fatal PHP error


 Ah yes... that would do it. How embarrassing! But another respondent
brought
 up an interesting question. Why does this error not show up every time? As
 written, it is a basic syntactical error. I tested this thing up and down;
I
 test it in production every day.

 Ah it's always something thanks much.


 Philip Olson wrote in message ...
  Call to unsupported or undefined function srtoupper() in on line
 82.
 
 srt != str (typo).
 
  if (strtoupper(substr($xmbrcode,11,1)) != B 
  strtoupper(substr($xmbrcode,11,1)) != P 
  srtoupper(substr($xmbrcode,11,1)) != H 
  srtoupper(substr($xmbrcode,11,1)) != O) {
 
 See above.  Btw, consider something like:
 
   $str = '123456789abcdef';
   $bad = array('B','P','H','O');
 
   if (in_array(strtoupper($str{11}),$bad)) {
   echo 'boo';
   }
 
 I can't believe people code on Christmas :)
 
 Warm regards,
 Philip Olson
 



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]