Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 511
  • Last Modified:

PHP Parse error: parse error, unexpected T_STRING in

PHP Parse error:  parse error, unexpected T_STRING in abc.php  on line 2:
I'm getting this on Linux environment but the same script works on Windows box.

Anything wrong?

the contents of the abc.php is as follows:




<?php header('Content-type: text/xml'); ?>
<?xml version="1.0" encoding="utf-8" ?>
<categories>
<?php
 
include 'config.php';
$con = mysql_connect($dbhost, $dbuser, $dbpass);
if (!$con)
{
  die('Could not connect: ' . mysql_error());
}
 
..
..
..
 
?>
</categories>

Open in new window

0
SimonHowald
Asked:
SimonHowald
  • 3
  • 2
1 Solution
 
aldanchCommented:
Try changing:
OLD
<?xml version="1.0" encoding="utf-8" ?>
 
NEW
<? echo "<?xml version='1.0' encoding='utf-8' ?>"; ?>

Open in new window

0
 
SimonHowaldAuthor Commented:
Thanks it worked. One more question before I close this chain...
why do we need to do this?
0
 
SimonHowaldAuthor Commented:
you are PHP Genius!
0
 
aldanchCommented:
The XML headers use "<?" and "?>" ...just like PHP ;)

PHP didn't know how to handle "xml version..." so you had to echo it.

Hope that helps!
0
 
SimonHowaldAuthor Commented:
thanks!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now