I'm designing a site using one of those, er, webdesgner programs. I just uploaded it, and got the following message:

Parse error; unexpected T_STRING in (blah blah)

Here's my code:

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title></title><meta http-equiv="refresh" content="0;url= Intro/Main.html" /></head><body></body></html>

Help, please?

Dani AI

Generated

Short answer: this is a PHP parse error, not an HTML problem. is right to call it a PHP error, and is right to check any files you include (like your Intro/Main.html) for stray code. The most common cause for the exact message you saw is the XML declaration at the top of a file being treated as a PHP opening tag (<?) when the server accepts short PHP open tags.

Quick checks to run:

  • Verify whether the file is being parsed by PHP (is it .php, or does the host parse .html through PHP?).
  • Put a tiny test file on the server to see PHP settings and error output:
<?php
phpinfo();
?>

Look at the value of short_open_tag and the error log entry (the parse error message usually includes the filename and line number).

Practical fixes:

  • Output the XML declaration from PHP so the literal <?xml never appears in the source that the PHP parser sees. For example:
<?php
echo '<?' . 'xml version="1.0" encoding="UTF-8"?' . '>';
?>
  • If you are simply redirecting, use a server-side redirect instead of a meta refresh:
<?php
header('Location: /Intro/Main.html', true, 302);
exit;
?>
  • If you control PHP settings, disable short open tags in php.ini (or ask the host to do so). On some Apache/mod_php setups you can set this in .htaccess, but that will cause a 500 error on many shared hosts—ask support first.

If the error persists, post the exact parse error line/filename (as shown in the server error) and check the included files for stray <? sequences. See the PHP manual entry for short_open_tag for configuration details: short_open_tag ini setting.

Recommended Answers

All 2 Replies

That is a PHP error, but you haven't posted any PHP code for us to look at...

Agreed - something very strange. The error might be in the "main.html" file you're referencing but haven't shown.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.