PHP Development
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Remember me

Go Back   Dev Articles Community ForumsProgrammingPHP Development

Add This Thread To:   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
Unread Dev Articles Community Forums Sponsor:
Old March 24th, 2008, 10:08 AM
sheel331 sheel331 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
Join Date: Mar 2008
Posts: 1 sheel331 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 m 18 sec
Reputation Power: 0
Parse errors - Unexpected T_CONSTANT_ENCAPSED_STRING


I am extremely new to coding in PHP and would appreciate if I could get some assistance on an error I'm receiving in one of my template files. I am getting this error:

PHP Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in header_sgs.html

on this code:

include '\template\navbar.html';

$fullPath = explode('/', $_SERVER['PHP_SELF']);
echo "The foldername $fullPath[0]";
echo "The filename $fullPath[1]";
if (file_exists('\template\'.$fullPath[1].'.html')) {
include 'c:\inetpub\webroot\soa\template\'.$fullPath[1].'.html';
} else if (file_exists('\template\'.$fullPath[2].'.html')) {
include 'c:\inetpub\webroot\soa\template\'.$fullPath[2].'.html';
echo "<ul id=\"secondaryNav\" ></ul>";


<div id="page">

if (file_exists("\Images\".$fullPath[1].".gif")) {
echo "<img src="\Images\".$fullPath[1].".gif\" alt=\"".$fullPath[1]."\" />";
}else if (file_exists('\Images\'.$fullPath[1].'.jpg')) {
echo "<img src="\Images\".$fullPath[1].".jpg\" alt=\"".$fullPath[1]."\" />";


It says it's failing on the first "if(file_exists...)" piece, but unfortunately, I'm too new to this to understand why it's failing. Help would be greatly appreciated!

Sheel Shah

Reply With Quote
Old March 24th, 2008, 11:11 PM
Mittineague's Avatar
Mittineague Mittineague is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
Join Date: Jul 2005
Location: West Springfield, Massachusetts
Posts: 552 Mittineague User rank is Private First Class (20 - 50 Reputation Level)Mittineague User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 1 Day 9 h 1 m 33 sec
Reputation Power: 14

Hi sheel331, welcome to the forums
It's easy to get lost when escaping and concatenating.
PHP considers text that's not in quotes to be PHP code, Variables start with $, constants don't.
Take a close look at
PHP Code:
echo "<img src="\Images\".$fullPath[1].".gif\" alt=\"".$fullPath[1]."\" />";
}else if (
file_exists('\Images\'.$fullPath[1].'.jpg')) {
echo "<img src="\Images\".$fullPath[1].".jpg\" alt=\"".$fullPath[1]."\" />"; 

I find it helpful to use whitespace in my code, Both for indentation and separation. eg. instead of
PHP Code:
if($var == 1){
$var2 == 2){
something more like
PHP Code:
if($var == 1)
$var2 == 2)
$var "moretext" $var2 "</span>

it makes the code easier to read for me.

BTW, if you put your code inside BBtags, the color syntax highlighting will help.
WP plugins - Error Reporting, Clean Options

Last edited by Mittineague : March 24th, 2008 at 11:46 PM. Reason: added tip

Reply With Quote

Viewing: Dev Articles Community ForumsProgrammingPHP Development > Parse errors - Unexpected T_CONSTANT_ENCAPSED_STRING

Developer Shed Advertisers and Affiliates

Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 

Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.

© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap