Archive for November, 2008

xml on php 5.1.x and obsolete google code fix

Some of the google php example code does not work in php 5 dot something.

And also you might find this map stuff certainly wont work properly in the versions of Firefox that exist at the time of this post. Something to do with ajax I believe. This code fixes that.

Over the years, lots of people hunting down fatal errors like:

undefined function: domxml_open_mem() or

Call to undefined function domxml_new_doc()

and its evident they are trying to make work the same sample code that I have. (The correct code is now on the google site btw)
The problem might be that they are using the wrong version of code with the release of PHP they have installed. The internet has been sending people down the wrong tracks trying to solve the problem.
It is also apparent that 5.x of PHP has, by default, the modules available for handling php.
Some basic checks first before moving onto the code:

To get it working in Centos you need to have  libxml2.x86_64 0:2.6.26-2.1.2.6 libxml2.i386 0:2.6.26-2.1.2.6

which means yum install libxml2

You should check the modules dir, e.g. /usr/lib64/php/modules/ for the presence of dom.so

Look at your php.ini (usually in /etc)

extension=dom.so

may not be necessary, errors like

PHP Warning: Module ‘mysql’ already loaded in Unknown on line 0 that appear when trying to run code from the command line may occur because in /etc/php.d/mysql.ini the module is already declared and subsequently loaded, therefore you can edit out the extentions = section of your /etc/php.ini

I’ve butchered the code of Google to suit my own application and table def. The critical lines changed are

$doc = new DOMDocument(‘1.0′);    (was create_document)
$node = $doc->createElement ….    (was create_element)
$doc->appendChild($node) …          (was append_child)
$newnode->setAttribute(“…             (was set_attribute)
$xmlfile = $doc->saveXML($markers_node);           (was dump_mem)

<?php

require(“./phpsqlajax_dbinfo.php”);

// Start XML file, create parent node

$doc = new DOMDocument(‘1.0′);

$markers_node = $doc->createElement(“markers”);$parnode = $doc->appendChild($node);
//markers_node is a node we’ll need as part of the FF fix. Basically somehow an extra line gets inserted which contains whitespace which leads to the error, Error: XML or text declaration not at start of entity. It will still work in IE though.

// Opens a connection to a mySQL server

$connection=mysql_connect ($mysql_host, $mysql_login, $mysql_pass);

if (!$connection) {

die(‘Not connected : ‘ . mysql_error());

}
// Set the active mySQL database

$db_selected = mysql_select_db($mysql_db, $connection);

if (!$db_selected) {

die (‘Can\’t use db : ‘ . mysql_error());

}
// Select all the rows in the markers table

$query = “SELECT * FROM ch_points WHERE 1″;

$result = mysql_query($query);

if (!$result) {

die(‘Invalid query: ‘ . mysql_error());

}
header(“Content-type: text/xml”);
// Iterate through the rows, adding XML nodes for each

while ($row = @mysql_fetch_assoc($result)){

// ADD TO XML DOCUMENT NODE

$node = $doc->createElement(“marker”);

$newnode = $parnode->appendChild($node);
$newnode->setAttribute(“name”, $row['owner']);

$newnode->setAttribute(“address”, $row['postcode']);

$newnode->setAttribute(“lat”, $row['lat']);

$newnode->setAttribute(“lng”, $row['lon']);

$newnode->setAttribute(“type”, $row['phases']);

}
$xmlfile = $doc->saveXML($markers_node);
//This is the other part of the firefox fix. Just pump out the nodes we need via markers_node.
echo $xmlfile;
?>

Leave a Comment

Warning to customers of BitDefender

Once BitDefender has your card details you’re screwed.

Another faceless company that treats you like dirt once they have your payment.

Not all software is bad. In 2007 I discovered fabulous packages like OpenLaszlo and Blender – so good they are beyond words. But at the other end of the spectrum, little is more is appauling than BitDefender.

I chose the product to protect my PC from viruses etc. based on poll results which, if my experience is anything to go by, these results are completely bogus and probably rigged. 

I bought BitDefender for 4 machines. One machine is on 24/7 as it forms part of a security system.
It became unstable and ran out of memory – despite increasing the swapfile to its limits, it had to be rebooted weekly.

The removal of BitDefender has since resulted in complete stability and it only requires boots after mandatory OS patches.

2 other machines became increasinly sluggish and unuseable. BitDefender services started crashing and refused to start, warning me my machine was not protected. Not the sort of thing I wanted to read.

After a catalogue of problems, I canned BitDefender and tried McAfee and AVG – these were found be far more suitable – the removal of BitDefender offered a noticeable performance increase on these machines.

BitDefender have ignored what is now 4 communications in cancelling auto-renewals. This is something that should be possible to be done through their web interface but unfortunately, they have constructed it in such a way that you can’t cancel (at least I can’t find a way to and have screen-shotted their web interface.)

Taking that on board with the fact that they ignore web and standard emails to them, you are left with facing the problem of cancelling your credit card. If they wont communicate then there is no other option: either take the renewal or cancel the card or force the card company to get involved (the least painful).

Frankly this is an awful company with zero PR cabability and an inadequate technical support department that does not seem to be able to read basic English.

Leave a Comment

load words into mysql table using infile

mysql> load data infile ‘/mnt/everyone/wordlist.txt’ into table words fields terminated by ‘\r’;

where the table is called words and has a field called word

Leave a Comment