Help! I am brand new at writing php and have an error that I can't see. I am totally new at PHP and am wading in with both feet. I tried to change a header in my osCommerce store setup. I am making the changes in the header.php file and I am now getting the following error message: Parse error: parse error, unexpected '<' in /home/cteshopp/public_html/osCommerce/catalog/includes/header.php on line 17


ORIGINAL PHP

<td valign="middle"><?php echo '<a href="' . tep_href_link (FILENAME_DEFAULT ) . '">' . tep_image(
DIR_WS_IMAGES . 'oscommerce.gif', 'osCommerce') . '</a>'; ?> </td>

OSCOMMERCE RECOMMENDED CHANGE TO PHP

<td vAlign=center><?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT) . '">' . tep_image(DIR_WS_IMAGES . 'your.gif', ‘your store name') . '</a>'; ?></td>

CURRENT PHP PROMPTING ERROR

<TR class=header>
<TD vAlign=center><?php echo '<a href="' . tep_href_link (FILENAME_DEFAULT ) . '">' . tep_image(DIR_WS_IMAGES . 'oscommerce.gif', 'osCommerce') . '</a>'; ?></TD>
<TD vAlign=bottom align=right><?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT, '', 'SSL') . '">' . tep_image(DIR_WS_IMAGES . 'header_account.gif', HEADER_TITLE_MY_ACCOUNT) . '</a>&nbsp;&nbsp;<a href="' . tep_href_link

I know it something simple like a “ or ‘ or a . that is missing and is probably in one of the surrounding lines. I just don’t see it. Any help I can get will be greatly appreciated. Until I resolve this I can't get my osCommerce store to load! Is there a tool that helps you isolate errors?

What helps sometimes is color highlighting. Proper use of code tags on the Daniweb boards gives you basic color highlighting as well as preserving indention to make code easier to read.

Where is line 17 in your source?

Puckdropper. Thank you so much for the reply. I am so new at this that a few days ago I didn't know PHP existed! The best I can do is to cut and paste the entire file here or email the file. Sorry about being so daft at all of this. The only programming that I have ever done was in basic and I did it on the original TI when computers were just coming out. Then I learned DOS and it became history and here I am in the muck and mire of PHP. I am still searching for a good teaching guide on PHP. I didn't write the file and was only trying to change the .gif and store name and ended up with the error.

There are two ways that I can read the file. These are cut and pasted directly from the file. #1

<?php
/*
$Id: header.php,v 1.42 2003/06/10 18:20:38 hpdl Exp $
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2003 osCommerce
Released under the GNU General Public License
*/
// check if the 'install' directory exists, and warn of its existence
if (WARN_INSTALL_EXISTENCE == 'true') {
if (file_exists(dirname($HTTP_SERVER_VARS['SCRIPT_FILENAME']) . '/install')) {
$messageStack->add('header', WARNING_INSTALL_DIRECTORY_EXISTS, 'warning'); } } // check if the configure.php file is writeable if (WARN_CONFIG_WRITEABLE == 'true') { if ( (file_exists(dirname($HTTP_SERVER_VARS['SCRIPT_FILENAME']) . '/includes/configure.php')) &amp;&amp; (is_writeable(dirname($HTTP_SERVER_VARS['SCRIPT_FILENAME']) . '/includes/configure.php')) ) { $messageStack-&gt;add('header', WARNING_CONFIG_FILE_WRITEABLE, 'warning'); } } // check if the session folder is writeable if (WARN_SESSION_DIRECTORY_NOT_WRITEABLE == 'true') { if (STORE_SESSIONS == '') { if (!is_dir(tep_session_save_path())) { $messageStack-&gt;add('header', WARNING_SESSION_DIRECTORY_NON_EXISTENT, 'warning'); } elseif (!is_writeable(tep_session_save_path())) { $messageStack-&gt;add('header', WARNING_SESSION_DIRECTORY_NOT_WRITEABLE, 'warning'); } } } // check session.auto_start is disabled if ( (function_exists('ini_get')) &amp;&amp; (WARN_SESSION_AUTO_START == 'true') ) { if (ini_get('session.auto_start') == '1') { $messageStack-&gt;add('header', WARNING_SESSION_AUTO_START, 'warning'); } } if ( (WARN_DOWNLOAD_DIRECTORY_NOT_READABLE == 'true') &amp;&amp; (DOWNLOAD_ENABLED == 'true') ) { if (!is_dir(DIR_FS_DOWNLOAD)) { $messageStack-&gt;add('header', WARNING_DOWNLOAD_DIRECTORY_NON_EXISTENT, 'warning'); } } if ($messageStack-&gt;size('header') &gt; 0) { echo $messageStack-&gt;output('header'); } ?&gt; 
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR class=header>
<TD vAlign=center><?php echo '<a href="' . tep_href_link (FILENAME_DEFAULT ) . '">' . tep_image(DIR_WS_IMAGES . 'oscommerce.gif', 'osCommerce') . '</a>'; ?></TD>
<TD vAlign=bottom align=right><?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT, '', 'SSL') . '">' . tep_image(DIR_WS_IMAGES . 'header_account.gif', HEADER_TITLE_MY_ACCOUNT) . '</a>&nbsp;&nbsp;<a href="' . tep_href_link(FILENAME_SHOPPING_CART) . '">' . tep_image(DIR_WS_IMAGES . 'header_cart.gif', HEADER_TITLE_CART_CONTENTS) . '</a>&nbsp;&nbsp;<a href="' . tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL') . '">' . tep_image(DIR_WS_IMAGES . 'header_checkout.gif', HEADER_TITLE_CHECKOUT) . '</a>'; ?>&nbsp;&nbsp;</TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=1 width="100%" border=0>
<TBODY>
<TR class=headerNavigation>
<TD class=headerNavigation>&nbsp;&nbsp;<?php echo $breadcrumb->trail(' » '); ?&gt;</TD>
<TD class=headerNavigation align=right><?php if (tep_session_is_registered('customer_id')) { ?><A class=headerNavigation href="<?php echo tep_href_link(FILENAME_LOGOFF, '', 'SSL'); ?>"><?php echo HEADER_TITLE_LOGOFF; ?></A>&nbsp;|&nbsp; <?php } ?><A class=headerNavigation href="<?php echo tep_href_link(FILENAME_ACCOUNT, '', 'SSL'); ?>"><?php echo HEADER_TITLE_MY_ACCOUNT; ?></A>&nbsp;|&nbsp; <A class=headerNavigation href="<?php echo tep_href_link(FILENAME_SHOPPING_CART); ?>"><?php echo HEADER_TITLE_CART_CONTENTS; ?></A>&nbsp;|&nbsp; <A class=headerNavigation href="<?php echo tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'); ?>"><?php echo HEADER_TITLE_CHECKOUT; ?></A>&nbsp;&nbsp;</TD></TR></TBODY></TABLE><?php
if (isset($HTTP_GET_VARS['error_message']) && tep_not_null($HTTP_GET_VARS['error_message'])) {
?>
<TABLE cellSpacing=0 cellPadding=2 width="100%" border=0>
<TBODY>
<TR class=headerError>
<TD class=headerError><?php echo htmlspecialchars(urldecode($HTTP_GET_VARS['error_message'])); ?></TD></TR></TBODY></TABLE><?php
}
if (isset($HTTP_GET_VARS['info_message']) && tep_not_null($HTTP_GET_VARS['info_message'])) {
?>
<TABLE cellSpacing=0 cellPadding=2 width="100%" border=0>
<TBODY>
<TR class=headerInfo>
<TD class=headerInfo><?php echo htmlspecialchars($HTTP_GET_VARS['info_message']); ?></TD></TR></TBODY></TABLE><?php
}
?>

#2

add('header', WARNING_INSTALL_DIRECTORY_EXISTS, 'warning'); } } // check if the configure.php file is writeable if (WARN_CONFIG_WRITEABLE == 'true') { if ( (file_exists(dirname($HTTP_SERVER_VARS['SCRIPT_FILENAME']) . '/includes/configure.php')) && (is_writeable(dirname($HTTP_SERVER_VARS['SCRIPT_FILENAME']) . '/includes/configure.php')) ) { $messageStack->add('header', WARNING_CONFIG_FILE_WRITEABLE, 'warning'); } } // check if the session folder is writeable if (WARN_SESSION_DIRECTORY_NOT_WRITEABLE == 'true') { if (STORE_SESSIONS == '') { if (!is_dir(tep_session_save_path())) { $messageStack->add('header', WARNING_SESSION_DIRECTORY_NON_EXISTENT, 'warning'); } elseif (!is_writeable(tep_session_save_path())) { $messageStack->add('header', WARNING_SESSION_DIRECTORY_NOT_WRITEABLE, 'warning'); } } } // check session.auto_start is disabled if ( (function_exists('ini_get')) && (WARN_SESSION_AUTO_START == 'true') ) { if (ini_get('session.auto_start') == '1') { $messageStack->add('header', WARNING_SESSION_AUTO_START, 'warning'); } } if ( (WARN_DOWNLOAD_DIRECTORY_NOT_READABLE == 'true') && (DOWNLOAD_ENABLED == 'true') ) { if (!is_dir(DIR_FS_DOWNLOAD)) { $messageStack->add('header', WARNING_DOWNLOAD_DIRECTORY_NON_EXISTENT, 'warning'); } } if ($messageStack->size('header') > 0) { echo $messageStack->output('header'); } ?>

| | |


Sharron

Please wrap code in [ code ] tags. (No spaces.) When done, simply turn off the code tag with a slash. [ /code ]

This is part of the operational theory for HTML, too, which most PHP scripts output.

Puckdropper. Thank's for responding, but this is way beyond my abilities. I am frustrated to the point of tears. I am going to try another avenue. I would be happy just to have the old file back the way it was. I am going to try the OSC bulletin boards. Thanks again.

Why didn't you just save your GIF with the name 'oscommerce.gif' and overwrite the one on the server, rather then drop yourself into PHP at this level knowing what you do?

And formatting Sharron's cut-and-paste because she clearly isn't familiar with that function:

#1

<?php
/*
$Id: header.php,v 1.42 2003/06/10 18:20:38 hpdl Exp $
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2003 osCommerce
Released under the GNU General Public License
*/
// check if the 'install' directory exists, and warn of its existence
if (WARN_INSTALL_EXISTENCE == 'true') {
if (file_exists(dirname($HTTP_SERVER_VARS['SCRIPT_FILENAME']) . '/install')) {
$messageStack->add('header', WARNING_INSTALL_DIRECTORY_EXISTS, 'warning'); } } // check if the configure.php file is writeable if (WARN_CONFIG_WRITEABLE == 'true') { if ( (file_exists(dirname($HTTP_SERVER_VARS['SCRIPT_FILENAME']) . '/includes/configure.php')) &amp;&amp; (is_writeable(dirname($HTTP_SERVER_VARS['SCRIPT_FILENAME']) . '/includes/configure.php')) ) { $messageStack-&gt;add('header', WARNING_CONFIG_FILE_WRITEABLE, 'warning'); } } // check if the session folder is writeable if (WARN_SESSION_DIRECTORY_NOT_WRITEABLE == 'true') { if (STORE_SESSIONS == '') { if (!is_dir(tep_session_save_path())) { $messageStack-&gt;add('header', WARNING_SESSION_DIRECTORY_NON_EXISTENT, 'warning'); } elseif (!is_writeable(tep_session_save_path())) { $messageStack-&gt;add('header', WARNING_SESSION_DIRECTORY_NOT_WRITEABLE, 'warning'); } } } // check session.auto_start is disabled if ( (function_exists('ini_get')) &amp;&amp; (WARN_SESSION_AUTO_START == 'true') ) { if (ini_get('session.auto_start') == '1') { $messageStack-&gt;add('header', WARNING_SESSION_AUTO_START, 'warning'); } } if ( (WARN_DOWNLOAD_DIRECTORY_NOT_READABLE == 'true') &amp;&amp; (DOWNLOAD_ENABLED == 'true') ) { if (!is_dir(DIR_FS_DOWNLOAD)) { $messageStack-&gt;add('header', WARNING_DOWNLOAD_DIRECTORY_NON_EXISTENT, 'warning'); } } if ($messageStack-&gt;size('header') &gt; 0) { echo $messageStack-&gt;output('header'); } ?&gt; 
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR class=header>
<TD vAlign=center><?php echo '<a href="' . tep_href_link (FILENAME_DEFAULT ) . '">' . tep_image(DIR_WS_IMAGES . 'oscommerce.gif', 'osCommerce') . '</a>'; ?></TD>
<TD vAlign=bottom align=right><?php echo '<a href="' . tep_href_link(FILENAME_ACCOUNT, '', 'SSL') . '">' . tep_image(DIR_WS_IMAGES . 'header_account.gif', HEADER_TITLE_MY_ACCOUNT) . '</a>&nbsp;&nbsp;<a href="' . tep_href_link(FILENAME_SHOPPING_CART) . '">' . tep_image(DIR_WS_IMAGES . 'header_cart.gif', HEADER_TITLE_CART_CONTENTS) . '</a>&nbsp;&nbsp;<a href="' . tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL') . '">' . tep_image(DIR_WS_IMAGES . 'header_checkout.gif', HEADER_TITLE_CHECKOUT) . '</a>'; ?>&nbsp;&nbsp;</TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=1 width="100%" border=0>
<TBODY>
<TR class=headerNavigation>
<TD class=headerNavigation>&nbsp;&nbsp;<?php echo $breadcrumb->trail(' » '); ?&gt;</TD>
<TD class=headerNavigation align=right><?php if (tep_session_is_registered('customer_id')) { ?><A class=headerNavigation href="<?php echo tep_href_link(FILENAME_LOGOFF, '', 'SSL'); ?>"><?php echo HEADER_TITLE_LOGOFF; ?></A>&nbsp;|&nbsp; <?php } ?><A class=headerNavigation href="<?php echo tep_href_link(FILENAME_ACCOUNT, '', 'SSL'); ?>"><?php echo HEADER_TITLE_MY_ACCOUNT; ?></A>&nbsp;|&nbsp; <A class=headerNavigation href="<?php echo tep_href_link(FILENAME_SHOPPING_CART); ?>"><?php echo HEADER_TITLE_CART_CONTENTS; ?></A>&nbsp;|&nbsp; <A class=headerNavigation href="<?php echo tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'); ?>"><?php echo HEADER_TITLE_CHECKOUT; ?></A>&nbsp;&nbsp;</TD></TR></TBODY></TABLE><?php
if (isset($HTTP_GET_VARS['error_message']) && tep_not_null($HTTP_GET_VARS['error_message'])) {
?>
<TABLE cellSpacing=0 cellPadding=2 width="100%" border=0>
<TBODY>
<TR class=headerError>
<TD class=headerError><?php echo htmlspecialchars(urldecode($HTTP_GET_VARS['error_message'])); ?></TD></TR></TBODY></TABLE><?php
}
if (isset($HTTP_GET_VARS['info_message']) && tep_not_null($HTTP_GET_VARS['info_message'])) {
?>
<TABLE cellSpacing=0 cellPadding=2 width="100%" border=0>
<TBODY>
<TR class=headerInfo>
<TD class=headerInfo><?php echo htmlspecialchars($HTTP_GET_VARS['info_message']); ?></TD></TR></TBODY></TABLE><?php
}
?>

I think I figured it out... It's such a weird error, I'd have never thought to look for it. When I copied and pasted the code to my code editor (a souped up version of Notepad called ConText) and it showed most the code, starting at the comment // check if the configure.php file is writeable , as being on one line.

Try editing the file and putting the comment on its own line. Something like:

$messageStack->add('header', WARNING_INSTALL_DIRECTORY_EXISTS, 'warning'); } }
// check if the configure.php file is writeable
 if (WARN_CONFIG_WRITEABLE == 'true') { if ( (file_exists(dirname($HTTP_SERVER_VARS['SCRIPT_FILENAME']) . '/includes/configure.php')) &amp;&amp; (is_writeable(dirname($HTTP_SERVER_VARS['SCRIPT_FILENAME']) . '/includes/configure.php')) ) { $messageStack-&gt;add('header', WARNING_CONFIG_FILE_WRITEABLE, 'warning'); } } // check if the session folder is writeable if (WARN_SESSION_DIRECTORY_NOT_WRITEABLE == 'true') { if (STORE_SESSIONS == '') { if (!is_dir(tep_session_save_path())) { $messageStack-&gt;add('header', WARNING_SESSION_DIRECTORY_NON_EXISTENT, 'warning'); } elseif (!is_writeable(tep_session_save_path())) { $messageStack-&gt;add('header', WARNING_SESSION_DIRECTORY_NOT_WRITEABLE, 'warning'); } } } // check session.auto_start is disabled if ( (function_exists('ini_get')) &amp;&amp; (WARN_SESSION_AUTO_START == 'true') ) { if (ini_get('session.auto_start') == '1') { $messageStack-&gt;add('header', WARNING_SESSION_AUTO_START, 'warning'); } } if ( (WARN_DOWNLOAD_DIRECTORY_NOT_READABLE == 'true') &amp;&amp; (DOWNLOAD_ENABLED == 'true') ) { if (!is_dir(DIR_FS_DOWNLOAD)) { $messageStack-&gt;add('header', WARNING_DOWNLOAD_DIRECTORY_NON_EXISTENT, 'warning'); } } if ($messageStack-&gt;size('header') &gt; 0) { echo $messageStack-&gt;output('header'); } ?&gt;

You may have to look for other places where you need to put the code on seperate lines, it's a simple matter of looking for semicolons and braces (curly brackets or { }), I'm sure. (PHP uses semicolons to end lines, HTML sometimes uses them to end entities, but I don't think the system would care about too many new lines.

Snowdog, you were so sweet to post the formatted text for me. FYI all I did was replace my gif and store name and left the other text and then received the parse error. I was editing through vDeck which apparently is a no no because it adds unwanted commands, like \'s, to the existing code. osCommerce has a site where you can post problems and this appears to be a common problem. I have learned that there are a multitude of osCommerce users having parse error problems. These users were using Front Page, notepad, and other editing tools including OSC's tool.

Since my last post I downloaded EngSite Editor for PHP and used their debugging tool. Thanks to Snowdog and the editor I now know how A posting should look. The editor tells me which lines have an errors, but not how to fix them. I am trying to get an original copy of the file before editing it, so I can keep an original and see what changes when I use the editing tool.

Thank you Puckdropper for the advice on basic formatting. I did try to re-structure the lines in the EngSite editor and asked it to run and I still had a parse error on line 13. I will take your suggestions and give it another try.

I want to thank both of you for taking the time to try to help someone who is brand new to php. I have learned a lot in a week. #1 lesson NEVER MAKE CHANGES TO THE ORIGINAL FILE - USE A COPY - TEST IT AND THEN REPLACE THE ORIGINAL!

Sharron

I am now getting this parse error in the EnginSite Editor:
PHP Parse error: parse error, unexpected '<' in C:\Documents and Settings\Owner\My Documents\PHPtest2.php on line 11. Which is the following line:

<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
This article has been dead for over six months. Start a new discussion instead.