Category Archive:

Zend Server on Mac OS X phpMyAdmin import size problem

0

I just switched over from using windows for years to a mac. I installed Zend Server CE and when working with phpMyAdmin I needed to increase the upload limit in the php.ini file again so I could import a database. I modified the post_max_size and upload_max_filesize then restarted apache as I’ve done in the past. Phpmyadmin still said 2048kb max file size for the import. I finally found the solution here http://stackoverflow.com/questions/3958615/import-file-size-limit-in-phpmyadmin . Apparently phpMyAdmin is running under Lighttpd and has it’s own php.ini file located here /usr/local/zend/gui/lighttpd/etc/php-fcgi.ini . Modify the post_max_size and upload_max_filesize values in that file then restart apache. See my post on how to restart Zend Server CE apache on Mac OS X.

Posted in: Development, Mac OS X, MySQL, PHP

Continue Reading

PHP Dom nodevalue HTML lost

1

Today I got stuck for a while working with PHP’s DOM functions. I have a short script that calls a web page, extracts the HTML , then using xpath extracts only a portion of the HTML . I wanted to capture the HTML subset and save it to a file. Using the DOM’s “nodeValue” method stripped all the HTML once assigned to my variable $priceSheetHtml! Why? It replaced the HTML with newline and return characters. Here is my original script that theoretically should have worked, but didn’t.

//get page html
$pageHtml = file_get_contents('http://' . $_SERVER['SERVER_NAME'] . BASE_URL . 'priceSheet');		
 
//extract only the html we need
$doc = new DOMDocument();
$doc->loadHTML($pageHtml);
$domxpath = new DOMXpath($doc);
$nodeList = $domxpath->query('//table[@id="priceSheet"]');
$priceSheetHtml = $nodeList->item(0)->nodeValue;

To get the HTML, you have to create a second DOMDocument, import and then append the node from the first DOMDocument, then call saveHTML() as below. This will extract the HTML subset as needed. Shouldn’t there be an easier way to do this? How about a saveHTML() method for use on the node list item?

//get page html
$pageHtml = file_get_contents('http://' . $_SERVER['SERVER_NAME'] . BASE_URL . 'priceSheet');		
 
//extract only the html we need
$doc = new DOMDocument();
$doc->loadHTML($pageHtml);
$domxpath = new DOMXpath($doc);
$nodeList = $domxpath->query('//table[@id="priceSheet"]');
 
/**
 * create second dom document, import the above node, then use the saveHTML()
 * method of dom document to extract the html
 */ 
$doc2 = new DOMDocument();
$doc2->appendChild($doc2->importNode($nodeList->item(0), true));
$priceSheetHtml = $doc2->saveHTML();
Posted in: Development, PHP

Continue Reading

How To Extract SimpleXMLElement Object Value

1

I’m working with Google’s geocode API today and used xpath to extract the data I needed from the XML returned.

$xml = simplexml_load_file('http://maps.googleapis.com/maps/api/geocode/xml?address=' . $address . '&sensor=false');
 
//use xpath to extract lat and long
$latitude = $xml->xpath('/GeocodeResponse/result/geometry/location/lat');		
 
print_r($latitude[0]);

The code above produces the following output:

SimpleXMLElement Object
(
    [0] => 42.3584308
)

The problem is, how I can I just get 42.3584308 so it can be used. No combination of $latitude[0][0] works. After some digging and trying things out, I found the solution was to type cast the object to a string like this

print_r((string)$latitude[0]);

The above code produces 42.3584308. Now you can use the value as needed.

Posted in: Development, PHP
Tags: ,

Continue Reading

Create a symbolic link on Windows

1

Today I created symbolic link to a config file on our server. More specifically, a link to config.php, which exists outside of the document root of our website. Creating the link on Linux was simple, but with windows it was a bit more tricky. I found a good resource here that describes the types of symbolic links for windows http://www.maxi-pedia.com/mklink .

If I have the following directory structure C:\Program Files (x86)\Zend\Apache2\htdocs\application_root\public\ . I want the config.php file to exist within application_root, and I have index.php residing within the public directory. At the top of index.php, I’d write

require('/config.php');

The config.php file is not really at the root of the public directory where PHP would expect it to be, but rather one level deeper within application_root.

To setup the symbolic link, do the following

  1. Open a windows command prompt and change your directory to where you’d like the symbolic link to exist, in my case it is C:\Program Files (x86)\Zend\Apache2\htdocs\application_root\public\
  2. Run the following command mklink config.php “C:\Program Files (x86)\Zend\Apache2\htdocs\themlsonline\config.php”
  3. Open your apache conf file where the virtual host is specified and add “Options Indexes FollowSymLinks” within the node. More on this here http://www.maxi-pedia.com/FollowSymLinks.
Posted in: Apache, Development, PHP

Continue Reading

Zend Unknown record property / related component Error

0

I’ve had this troublesome error pop up twice now and the problem is not what you think. I’m working with Zend Framework and in one of my controllers I created the variable “private $_request” and with Zend Studio 7.2, I added this property to my “expressions” view to I could monitor its value. After a while I decided to no longer use that property and removed it from my code, but it was still being monitored in the expressions view of Zend Studio. That’s when the “Unknown record property / related component “$_request” on objectName” errors started. It’s not a coding error of any sort; it’s a software issue that somehow looks like a coding issue. I am using Zend Server and their debugger, so the connections between each software may be causing problems.

Posted in: PHP
Tags:

Continue Reading