DTP


 
Lively discussions on the graphic arts and publishing — in print or on the web


Go Back   Desktop Publishing Forum > General Discussions > Web Site Building & Maintenance

Reply
 
Thread Tools Display Modes
Old 06-22-2007, 05:21 AM   #1
CarlSeiler
Member
 
CarlSeiler's Avatar
 
Join Date: Oct 2005
Location: Denton, TX
Posts: 271
Default unexpected T_STRING in line 1

I have created a new page, which I expect to eventually have to add some dynamic content to. In anticipation of this, I've given the page a *.php extension. Currently there is no php in the file. I uploaded the file to the server, and when I visit the page, I get an error stating "Parse error: parse error, unexpected T_STRING in /home/content/O/p/e/OpeningDoors05/html/fraud-alert-en.php on line 1"

I haven't been able to figure out what this error means exactly, but after reading several posts by others with similar messages, it seems to frequently occur when people have unbalanced quotes. I'm reasonably certain that my quotes are balanced, and the document is valid XHTML.

What I've found is that if I convert it over to HTML 4.01 with Tidy, and get rid of my <?xml line it works--the server shows the page. Does php not like XHTML with the ?xml at the top?
CarlSeiler is offline   Reply With Quote
Old 06-22-2007, 11:27 AM   #2
Barrie Greed
Member
 
Join Date: May 2006
Location: Stringston, Somerset,UK
Posts: 111
Default Short tags conflict with xhtml

Quote:
Originally Posted by CarlSeiler View Post
What I've found is that if I convert it over to HTML 4.01 with Tidy, and get rid of my <?xml line it works--the server shows the page. Does php not like XHTML with the ?xml at the top?
Basically yes. PHP can be set up to use short tags <? ?> as well as the normal <?php ?>. When you use this with xhtml, PHP trips over the opening <? of the xml definition.

You can turn short tags off in the Language Options section of php.ini.

Barrie Greed
Barrie Greed is offline   Reply With Quote
Old 06-22-2007, 03:59 PM   #3
CarlSeiler
Member
 
CarlSeiler's Avatar
 
Join Date: Oct 2005
Location: Denton, TX
Posts: 271
Default

Quote:
Originally Posted by Barrie Greed View Post
Basically yes. PHP can be set up to use short tags <? ?> as well as the normal <?php ?>. When you use this with xhtml, PHP trips over the opening <? of the xml definition.

You can turn short tags off in the Language Options section of php.ini.
Thanks. Easily explained. Now, I just have to find out if I have any such control over the php.ini, which I don't think I do. The hosting was arranged through GoDaddy by someone else.

Carl
CarlSeiler is offline   Reply With Quote
Old 06-23-2007, 12:36 AM   #4
iamback
Member
 
iamback's Avatar
 
Join Date: Oct 2005
Location: Amsterdam, NL
Posts: 4,894
Default

Quote:
Originally Posted by CarlSeiler View Post
Thanks. Easily explained. Now, I just have to find out if I have any such control over the php.ini, which I don't think I do. The hosting was arranged through GoDaddy by someone else.
The setting variable in question is short_open_tag which according to this page has a configurable setting of "PHP_INI_PERDIR"; that means you cannot set it dynamically from a script, you can set it only in php.ini, .htaccess or httpd.conf.

Now on GoDaddy you're unlikely to have access to your own php.ini, and unless you have a VPS you won't have access to httpd.conf either. That leaves .htaccess - so you need to find out if your hosting allows you to create .htaccess files (and if the server's Options are set to AllowOverride - otherwise you still can't specify it there).

If you can, you need to create a .htaccess file in the relevant directory (or topmost directory) and add this line to it:
Code:
php_flag short_open_tag off

   
__________________
Marjolein Katsma
Look through my eyes on Cultural Surfaces (soon!), My ArtFlakes shop and Flickr.
Occasionally I am also connecting online dots... and sometimes you can follow me on Marjolein's Travel Blog
iamback is offline   Reply With Quote
Old 06-23-2007, 01:08 PM   #5
CarlSeiler
Member
 
CarlSeiler's Avatar
 
Join Date: Oct 2005
Location: Denton, TX
Posts: 271
Default

Quote:
Originally Posted by iamback View Post
If you can, you need to create a .htaccess file in the relevant directory (or topmost directory) and add this line to it:
Code:
php_flag short_open_tag off
Thanks for the exact wording, Marjolein. I think that may be my only option at this point, and I can't recall if I have control over the .htaccess file or not. Otherwise, I'll just keep things without the <?xml if I'm expecting to use php. I see that XHTML 1.0 at the W3C site says:

"An XML declaration is not required in all XML documents; however XHTML document authors are strongly encouraged to use XML declarations in all their documents."
Carl
CarlSeiler is offline   Reply With Quote
Old 06-24-2007, 03:16 AM   #6
Barrie Greed
Member
 
Join Date: May 2006
Location: Stringston, Somerset,UK
Posts: 111
Default

Carl

You can always use the PHP Manual alternative suggestion of using PHP to print the xml declaration:
<?php echo '<?xml version="1.0"?>'; ?>

Barrie Greed
Barrie Greed is offline   Reply With Quote
Old 06-24-2007, 07:03 AM   #7
CarlSeiler
Member
 
CarlSeiler's Avatar
 
Join Date: Oct 2005
Location: Denton, TX
Posts: 271
Default

Quote:
Originally Posted by Barrie Greed View Post
<?php echo '<?xml version="1.0"?>'; ?>
Duh! Thanks! That's so obvious, but I was thinking so inside the box, I wasn't even thinking of using php to solve my problem.
CarlSeiler is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Bryce 6 (and the Vue product line) Andrew B. Software 1 11-14-2006 07:48 AM
First line and letter formatting Bo Aakerstrom Web Site Building & Maintenance 8 08-24-2006 08:45 AM
Off line for a (short) week iamback The Corner Pub 3 08-10-2006 12:53 PM
Your Driver's License on Line George The Corner Pub 7 11-04-2005 09:32 PM


All times are GMT -8. The time now is 12:15 AM.


Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Contents copyright 2004–2014 Desktop Publishing Forum and its members.