php text-resizer gives error on laptop but not on desktop
Posted by: oldcelt (---.115.47.39.plusnet.pcl-ag01.dyn.plus.net)
Date: June 28, 2011 02:06PM

A php program called text-resizer is in the public domain and I've been using it on my desktop perfectly well. Also uploaded to my web site where it performs as expected whether accessed through the pc or the laptop.

Have installed wampserver 2 (freshly downloaded) onto the laptop and it comes up with an error when using exactly the same code as that on the pc.

Reported error:-
Undefined index: set_text in C:\Wamp\www\text-resizer.class.php on line 39

I can see nothing wrong with it and, as I say, it works perfectly well with the same version of wampserver on the pc.

Here's the code:
<?php

/*
*
* author: kumar@chicagomodular.com
* css help from Collin Olan <collin@staartje.com>
*
* Release: 2003-08-22
*
*

Short Description: Resizes text on a page using styles and sessions.

Full Description: Thanks to the cascading nature of CSS, a simple font-size percentage can be included in the head of any page to facilite this text resizer. It will not disrupt any other attribute of your styles except the body's font size.
Directions: Instantiate this object on any page where you want to use the resizer, call ProcessTextReset(), and
reset the text size by passing query string variables: set_text=smaller, set_text=larger, or set_text=normal (the
class uses sessions to remember values). The font size is reset to a percentage of the default size of your user's
browser. It should be compatible with all of PHP 4; let me know if you find problems.

*
*/

class TextResizer
{

var $PercentageIncrement = 10; var$TextPercentage;

function TextResizer()
{
session_start();
} // END function TextResizer()

function GetGetVar($VarName) { if(!empty($GLOBALS['HTTP_GET_VARS'][$VarName]))$_GET[$VarName] =$GLOBALS['HTTP_GET_VARS'][$VarName]; return$_GET[$VarName]; } // END function GetGetVar($VarName)

function GetSessionVar($VarName) { if(!empty($GLOBALS['HTPP_SESSION_VARS'][$VarName]))$_SESSION[$VarName] =$GLOBALS['HTPP_SESSION_VARS'][$VarName]; return$_SESSION[$VarName]; } // END function GetSessionVar($VarName)

function GetTextPercentage()
{
if(!empty($this->TextPercentage)) return$this->TextPercentage;
$this->TextPercentage =$this->GetSessionVar('TextPercentage');
if(!empty($this->TextPercentage)) return$this->TextPercentage;
$this->TextPercentage = 100; return$this->TextPercentage;
} // END function GetTextPercentage()

# function PrintStyle()
#
# this style must be printed after any other styles are defined.
# It should not disrupt any other part of your style except the body's
# font size
function PrintStyle()
{
$TextPercentage =$this->GetTextPercentage();
$Style = <<<Style <style type="text/css"> body { font-size:$TextPercentage%; } </style>

Style;
echo $Style; } // END function PrintStyle() function ProcessTextReset() {$SetText = $this->GetGetVar('set_text');$TextPercentage = $this->GetTextPercentage(); if(empty($TextPercentage)) $TextPercentage = 100; switch($SetText) {
case 'smaller':
$TextPercentage -=$this->PercentageIncrement; if(empty($TextPercentage))$TextPercentage = 100;
if($TextPercentage <= 90)$TextPercentage = 90;
break;
case 'larger':
$TextPercentage +=$this->PercentageIncrement;
if($TextPercentage >= 110)$TextPercentage = 110;
break;
case 'normal':
$TextPercentage = 100; break; } // END switch($SetText) {
$this->SetTextPercentage($TextPercentage);
} // END function ProcessTextReset()

function SetPercentageIncrement($PercentageIncrement) {$this->PercentageIncrement = $PercentageIncrement; } // END function SetPercentageIncrement($PercentageIncrement)

function SetSessionVar($VarName,$Value)
{
if(isset($_SESSION))$_SESSION[$VarName] =$Value;
else
$GLOBALS['HTTP_SESSION_VARS'][$VarName] = $Value; } // END function SetSessionVar($VarName,$Value) # function SetTextPercentage($TextPercentage)
#
# this method sets the percentage for the text, i.e. 100%
# If you want to give your users a static number of text percentage options
# you should create a new processing function like ProcessTextReset() to wrap
# around this function
function SetTextPercentage($TextPercentage) {$this->SetSessionVar('TextPercentage',$TextPercentage);$this->TextPercentage = $TextPercentage; } // END function SetTextPercentage($TextPercentage)

} // END class TextResizer

?>

Ken

Re: php text-resizer gives error on laptop but not on desktop
Posted by: stevenmartin99 (---.251.255.14.threembb.ie)
Date: June 28, 2011 05:49PM

The var isn't declared before it's used

Wamp is setup with this warning on Where as a production server would have it turned off

You can change warning in the php.ini

Just left click wamp>php>php.ini

Find

Error-level = EALL

and change to

E_ALL & ~E_NOTICE

save and restart wamp

Please don't follow my code exactly- I'm on phone and some lil detail might be wrong -
It's fully explained in the file before the line

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]

Re: php text-resizer gives error on laptop but not on desktop
Posted by: oldcelt (---.115.47.39.plusnet.pcl-ag01.dyn.plus.net)
Date: June 29, 2011 11:02AM

Thanks Steven

That now works fine. Much appreciated,
Ken

Re: php text-resizer gives error on laptop but not on desktop
Posted by: oldcelt (---.115.47.39.plusnet.pcl-ag01.dyn.plus.net)
Date: June 29, 2011 11:07AM

Strangely enough, the ini file on the desktop had Error-Level=E_ALL set but didn't throw up the warning!

Re: php text-resizer gives error on laptop but not on desktop
Posted by: stevenmartin99 (---.b-ras1.srl.dublin.eircom.net)
Date: June 29, 2011 03:57PM

the ini on the desktop?

maybe this php.ini has

display_errors = off
which will show no errors

regardless notices are not consistant errors...

the variable may be set in some sistuations.. coming from one page.. filling in a form or leaving a field blank etc.

so its hard to say if its the same circumstances.. but the best situation is

E_ALL for testing

and for production

display_errors = off

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]

Re: php text-resizer gives error on laptop but not on desktop
Posted by: oldcelt (---.115.47.39.plusnet.pcl-ag01.dyn.plus.net)
Date: June 29, 2011 05:03PM

Yep! You have it display_errors set to off. Thanks again.

What still puzzles me is that Wamp was installed on both machines from the same download, yet one had display_errors off and the other had it on!

Ken

Re: php text-resizer gives error on laptop but not on desktop
Posted by: stevenmartin99 (---.b-ras1.srl.dublin.eircom.net)
Date: June 29, 2011 05:09PM

maybe different php versions?

they change their mind alot on whats a production/testing best setting but in wamp i think its nearly on.

maybe you changed it on the menu yourself some time ago.

left click wamp>php>settings>display_errors

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]

Re: php text-resizer gives error on laptop but not on desktop
Posted by: oldcelt (---.115.47.39.plusnet.pcl-ag01.dyn.plus.net)
Date: June 29, 2011 06:09PM

Hmm! I certainly can't remember changing the setting but I have to admit it's possible - it has to be the reason I suppose. Both installations were made from the same download which was saved to my external backup HD.

Anyway, thanks a million for the help.

Ken