PHP Warning: DOMDocument::loadHTML(): htmlParseEntityRef: expecting ‘;’ in Entity, line: 2416

PHP Warning: DOMDocument::loadHTML(): htmlParseEntityRef: expecting ‘;’ in Entity, line: 2416

If you’re trying to parse the results of a webpage, either remotely or locally, you may have run into this error.   If you’re trying to iterate over the html elements, the DOM Document may be a good choice for you.  It easily allows you to select all the document elements that match your search.  IE, you can select all bolded elements and find out what is bolded.  The php code below is a simple way to load html into the DOM...

Read More

Dates & Datetimes when reading from MSSQL in PHP

Dates & Datetimes when reading from MSSQL in PHP

So it gets me every time I try to deal with dates in a query result when I’m getting rows from a MSSQL database in PHP. Normally I work with MySQL when I’m programming in PHP, but I have a hybrid application where .Net is used on the front end, and I do a bunch of back end things using PHP scripts. So here’s the issue. MSSQL doesn’t store things the same way MySQL does. MySQL seems to treat everything like a string. ...

Read More

“The program can’t start because php5ts.dll is missing from your computer” Error

I was trying to execute a PHP file via the command line on a windows machine and got the following error “the program can’t start because php5ts.dll is missing from your computer” Now executing PHP via the command line in Windows is different enough from Linux, I didn’t know what it needed. In Linux I would have install php-cli which should have come with all the dependancies. In Windows however, I fixed the issue by...

Read More

Removing extra spaces from within quotes of a string in PHP

Every once in a while, you may be building strings that include quoted material. The issue is that if you’re doing it programmatically, you may be doing something that quotes different parts of the string. The issue is, that if the field you’re pulling from doesn’t exist, you may leave yourself with extra spaces in your strings. See the example below. Table: A Columns: color,number,price,shape Row1: red,4,3.25,square Row2:...

Read More

ERROR: `phpize’ failed and make: *** [oauth.lo] Error 1

I recently tried to install oauth on Ubuntu and got two errors during the process. Unlike what is said, it was not the simple install from pecl. sudo pecl install oauth This should work, but it threw my first error ERROR: `phpize’ failed More searching revealed that the phpize script is found in the php5-dev package, and those who had the error installed that to make it work. sudo apt-get install php5-dev It got farther this time, but...

Read More

Parse a CSV file line in PHP

Parse a CSV file line in PHP

PHP has great string manipulation tools for importing files like fgets() to get a single line or file() to dump the lines into an array right at import. Explode is a great function when you start dealing with the contents of the file. However, if you’re bringing in a standardized file, like a CSV, there are some issues with explode. For instance, a comma may be in a string in the middle of the field, so you can’t break it apart on...

Read More