Wednesday 2 January 2013

Firefox disappointment

What has happened to Firefox?

It always used to be a reliable, honest, hassle-free browser. But when I found javascript from a shower called Superfish injected into my pages, I changed my view.

There seems to be no ready way for a user to find out which Add-On or Extension is responsible for interfering with pages.

Trial and error suggested that for me it was the FoxIt PDF reader that was responsible (but I am still not 100% sure). But why should one have to use trial and error. Where is the Firefox feature that quickly identifies running addons and extensions, and shows what each is doing to your browser?

Friday 15 June 2012

Building an SQL query in PHP: beware formulae

Got in trouble with this

$sql.=" SET commsq.attempts = $newNumberOfAttempts ";
$sql.=", commssitebasics.uNextContact =".$thisU+DEFINED_CONSTANT;
$sql.=", commssitebasics.somethingElse=2";
which produced a very odd result


SET commsq.attempts = 1 1, commssitebasics.somethingElse=2


what was happening? Answer: the first line is fine, but in the second line, PHP doesn't like the "+" and ignores everything before it, adding just the value of DEFINED_CONSTANT to the string. 


Answer - always put brackets around any appended value which is the result of a computation:


$sql.=", commssitebasics.uNextContact =".($thisU+DEFINED_CONSTANT);


Thursday 17 November 2011

jpgraph for php: The image xxxx cannot be displayed, because it contains errors ...

... or perhaps you have some blank space (perhaps a blank line??) before the opening PHP tag

Wednesday 9 March 2011

ezPDF - adding a horizontal rule

The ezPdf class for PHP is fairly basic, but none the worse for that. I found I couldn't get a Horizontal Rule to go below the text I'd just output, but it was very easy to write a function that would do it:

function ezHR($lineThickness){
//writes horizontal rule of given thickness, respecting left and right margins
$this->setLineStyle($lineThickness);
$y=$this->ezGetDy()-10;
$r=$this->ez['pageWidth']-$this->ez['rightMargin'];
$this->line($this->ez['leftMargin'],$y,$r,$y);
}


Add this to class.ezpdf.php and then call it with 
$pdf->ezHR(2);

Friday 4 March 2011

Troubleshooting php.exe when run from Task Scheduler

I looked high and low for ideas on how to keep open the output that flashes up when you run a php page using task manager (unless you write a bit of vbs to hide it entirely).

eg, when Task Scheduler runs:

C:\wamp\bin\php\php5.3.4\php.exe d:\test.php

how can you check to see whether there are errors in test.php? Obviously you could open as any other php page but what if the errors are only applicable to the page being called from Task Scheduler?

The nearest I have got is to open cmd.exe, and then paste in the command-line string.

Wednesday 23 February 2011

php "failed to open stream - no error"

Chased this error (when calling php function file_get_contents) for ages, and eventually spotted: a mal-formed URL: one of the slashes missing after "http:"

Why did it take so long? Because as part of my debugging I echoed the url that I was calling, then copied and pasted that into my browser (Firefox 3.6.13). Result - the page loaded fine.

Good old Firefox had corrected the error without comment.

Moral: sometimes fixing things quietly isn't as kindly an act as one might imagine.

Sunday 6 February 2011

PHP "Deprecated" error messages

PHP 5.3.x throws out plenty of "Deprecated" messages. Having set
error_reporting = E_ALL & ~E_DEPRECATED
and confirmed in phpinfo() that I was getting the expected value of 22527, I was still getting the wretched messages.

The cause?

This code, which an "include" called in my own coding as I launched each page:
error_reporting  (E_ALL);

doh!

(If you've found this, perhaps that is your problem, too?)