PHP Classes

$this error

Recommend this page to a friend!

      DHTML and CSS CAPTCHA  >  All threads  >  $this error  >  (Un) Subscribe thread alerts  
Subject:$this error
Summary:fatal error in my install
Messages:7
Author:Jim Lynn
Date:2008-05-16 14:13:39
Update:2008-05-19 13:42:12
 

  1. $this error   Reply   Report abuse  
Picture of Jim Lynn Jim Lynn - 2008-05-16 14:13:39
I get an error for line 58 in as_snipercaptcha.php for the line:

if($this-b_buffered) return $ret

php (5.0) errors with:

PHP Fatal error: Using $this when not in object context in /home/www/sniper/as_snipercaptcha.php on line 58

Any ideas?

  2. Re: $this error   Reply   Report abuse  
Picture of Alexander Selifonov Alexander Selifonov - 2008-05-16 15:34:34 - In reply to message 1 from Jim Lynn
You did not show your code. Anyway, I think You use "static" call CSniperCaptcha::DrawRefs(). So any $this references are invalid.

You should create new object $captcha = new CSniperCaptcha(),
and use $captcha->DrawRefs();

  3. Re: $this error   Reply   Report abuse  
Picture of Patrick Patrick - 2008-05-17 21:07:45 - In reply to message 2 from Alexander Selifonov
Hi!
I have also an error when starting this script.

I have downloaded the package and unzipped in my server and then launched sample.php to check if all is ok.

I get this:

As_SniperCaptcha using sample

Fatal error: Using $this when not in object context in C:\ZMWS\_web.zmwsc\captcha\as_snipercaptcha.php on line 58

.. and all stops..

Any ideas to solve this boring answer?
Thanks!

  4. Re: $this error   Reply   Report abuse  
Picture of Alexander Selifonov Alexander Selifonov - 2008-05-18 06:23:40 - In reply to message 3 from Patrick
I've fixed this issue, so I hope DrawRefs() now can be called as static method, CSniperCaptcha::DrawRefs().
(BTW, I didn't see this problem on my PHP 4.3.x and 5.2.x environements.)

  5. Re: $this error   Reply   Report abuse  
Picture of Patrick Patrick - 2008-05-18 09:33:47 - In reply to message 4 from Alexander Selifonov
Yes it works now!! Thanks for the fix!

Just a last question: The squares looks very small on my screen and I think that for bad eyes users, it would be difficult to click on the correct boxes.

Is it possible to increase the global size of the boxes? I see the command $captcha->Draw(8,3,12); in the code. 8 and 3 are the number of horizontal and vertical boxes, but what is 12?

I would like to display the double size as the current one.

Thanks for reply!

  6. Re: $this error   Reply   Report abuse  
Picture of Alexander Selifonov Alexander Selifonov - 2008-05-18 18:46:42 - In reply to message 5 from Patrick
3-rd parameter ($cellsize) is a cell size in pixels. If it's omitted, the size height is random number in a scope 10...20, and cell width - random in a scope of cell.height...height+10.
So You can use 3-rd parameter $cellsize to set your cell size. It's described in doc (htm).

  7. Re: $this error   Reply   Report abuse  
Picture of Jim Lynn Jim Lynn - 2008-05-19 13:42:13 - In reply to message 6 from Alexander Selifonov
Yes, it works perfectly now. Thanks for the quick response!