Browscap.ini throwing an error when loading PHP (command line - PHP_CLI)
I have a cronjob that summarize browser statistics. This cronjob loads data and then use the get_browser() PHP function to parse the browser information.
Here's what I did:
cd /etc/php5/cli/conf.d me@ubutnu:/etc/php5/cli/conf.d$ sudo wget http://browsers.garykeith.com/stream.asp?Lite_PHP_BrowsCapINI -O browscap.ini 2011-09-30 15:14:18 (890 KB/s) - `browscap.ini' saved [185384/185384]
Then the cronjob run:
php /usr/local/cron/summarizeStats.php --option=browserStats --date=yesterday
and I get this error:
PHP: syntax error, unexpected $end, expecting ']' in /etc/php5/cli/conf.d/browscap.ini on line 51
What am I doing wrong? Thanks
There is seemingly right now an error with those browsecap files. They seem to contain unescaped semicolons ";" in the browser spec. You can fix that using this little script:
<?php $browsecap = file('browscap.ini'); foreach( $browsecap as &$row ) if ( $row[ 0 ] == '[' ) $row = str_replace( ';', '\\;', $row ); file_put_contents( 'fixed_browscap.ini', $browsecap );
Browscap.ini throwing an error when loading PHP , Browscap.ini throwing an error when loading PHP (command line - PHP_CLI) This cronjob loads data and then use the get_browser() PHP function to parse� sed can be used to escape the semi-colon like so:. sed 's/;/\\\;/g' browscap. ini > browscap_escape. ini. This will catch all the comments as well but you could use sed again to catch those.
sed can be used to escape the semi-colon like so:
sed 's/;/\\\;/g' browscap.ini > browscap_escape.ini
This will catch all the comments as well but you could use
sed again to catch those.
As described here github.com/browscap/browscap/issues/119
FAQ - Chamilo LMS, a fault with apache, this is a php ini file parsing limitation. /7615290/browscap- ini-throwing-an-error-when-loading-php-command-line-php-cli� don't use the sed command above, it also strips off a character before or after the semi-colon. do, check if some character need escaping, example ';' or '?'
Command line options, Error 500 on new course page. Chamilo Configuration. Configuring browscap - ini-throwing-an-error-when-loading-php-command-line-php-cli/13459743#� Teams. Q&A for Work. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information.
PHP 5 ChangeLog, The list of command line options provided by the PHP binary can be queried at any time by running PHP with the -h switch: php [options] -a -a Run interactively -c <path>|<file> Look for php.ini file in this -z <file> Load Zend extension <file>. args. On success, the text No syntax errors detected in < filename> is written to� 6633 How to configure Spring to make JPA (Hibernate) and JDBC (JdbcTemplate or MyBatis) share the same transaction
- I just downloaded the latest browsecap file for php, and it is over 20,000 lines, so if it is saying unexpected $end at line 51, then the file you have is incomplete. Unexpected $end means that php encountered the end of a file when it wasn't expecting to. Did you download the browsecap file that is PHP compatible? Here is a link to the latest php browsecap.ini
- Didn't work for me. IEs where not recognized. I replaced the semicolons and ticks with asterisks inside my shell script and it worked again. Example:
sed -e '/^\[/ s/;/*/g' /etc/php5/apache2/browscap_orig.ini > /etc/php5/apache2/browscap.ini sed -i "/^\[/ s/'/*/g" /etc/php5/apache2/browscap.ini