954,576 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Parse error: syntax error, unexpected T_STRING

Hi,
i am new here and complete amateur to PHP. I get the above error on line 2. but i don't get it? Can someone help please?

<?php

function bp_dtheme_add_custom_header_support() {
	$get_current_scheme = get_option('dev_buddydaily_custom_style');
		if(($get_current_scheme == '') || ($get_current_scheme == 'default.css')) { 
			$headerpath = "%s/library/styles/images/default_header.jpg";
		}
		else{
			$headerpath = "%s/library/styles/";
			if ($get_current_scheme == "gossip.css"){
				$styledir = "gossip";
			}
			if ($get_current_scheme == "daily.css"){
				$styledir = "daily";
			}
			if ($get_current_scheme == "tabloid.css"){
				$styledir = "tabloid";
			}
			if ($get_current_scheme == "motoring.css"){
				$styledir = "motoring";
			}
			if ($get_current_scheme == "press.css"){
				$styledir = "press";
			}
			if ($get_current_scheme == "technology.css"){
				$styledir = "technology";
			}
			if ($get_current_scheme == "politics.css"){
				$styledir = "politics";
			}
			if ($get_current_scheme == "culture.css"){
				$styledir = "culture";
			}
			$headerpath .= $styledir;
			$headerpath .= "-images/default_header.jpg";
		}
	/* Set the defaults for the custom header image (http://ryan.boren.me/2007/01/07/custom-image-header-api/) */
	if (($get_current_scheme == "tabloid.css")||($get_current_scheme == "gossip.css")||($get_current_scheme == "culture.css")||($get_current_scheme == "politics.css")){
		define( 'HEADER_TEXTCOLOR', 'FFFFFF' );
	}
	else if ($get_current_scheme == "motoring.css"){
		define( 'HEADER_TEXTCOLOR', 'D5D5D5' );
	}
	else if ($get_current_scheme == "technology.css"){
		define( 'HEADER_TEXTCOLOR', '51ABC5' );
	}
	else {
		define( 'HEADER_TEXTCOLOR', '111111' );
	}
	
	define( 'HEADER_IMAGE', $headerpath ); // %s is theme dir uri
	define( 'HEADER_IMAGE_WIDTH', 950 );
	define( 'HEADER_IMAGE_HEIGHT', 300 );

	function bp_dtheme_header_style() { ?>
		<style type="text/css">
			#header { background-image: url(<?php header_image() ?>); }
			<?php if ( 'blank' == get_header_textcolor() ) { ?>
			#header h1 a {display: none; }
			#header h1 a:visited {display: none; }
			#header h1 a:hover {display: none; }
			<?php } else { ?>
			#header h1 a {color:#<?php header_textcolor() ?>;}
			#header h1 a:visited {color:#<?php header_textcolor() ?>;}
			#header h1 a:hover {color:#<?php header_textcolor() ?>;}
			<?php } ?>
		</style>
	<?php
	}

	function bp_dtheme_admin_header_style() { ?>
		<style type="text/css">
			#headimg {
				position: relative;
				color: #fff;
				background: url(<?php header_image() ?>);
				-moz-border-radius-bottomleft: 6px;
				-webkit-border-bottom-left-radius: 6px;
				-moz-border-radius-bottomright: 6px;
				-webkit-border-bottom-right-radius: 6px;
				margin-bottom: 20px;
				height: 100px;
				padding-top: 25px;
			}

			#headimg h1{
				position: absolute;
				bottom: 15px;
				left: 15px;
				width: 44%;
				margin: 0;
				font-family: Arial, Tahoma, sans-serif;
			}
			#headimg h1 a{
				color:#<?php header_textcolor() ?>;
				text-decoration: none;
				border-bottom: none;
			}
			#headimg #desc{
				color:#<?php header_textcolor() ?>;
				font-size:1em;
				margin-top:-0.5em;
			}

			#desc {
				display: none;
			}

			<?php if ( 'blank' == get_header_textcolor() ) { ?>
			#headimg h1, #headimg #desc {
				display: none;
			}
			#headimg h1 a, #headimg #desc {
				color:#<?php echo HEADER_TEXTCOLOR ?>;
			}
			<?php } ?>
		</style>
	<?php
	}
	add_custom_image_header( 'bp_dtheme_header_style', 'bp_dtheme_admin_header_style' );
}
if ( !defined( 'BP_DTHEME_DISABLE_CUSTOM_HEADER' ) )
	add_action( 'init', 'bp_dtheme_add_custom_header_support' );


?>
kunal_28parikh
Newbie Poster
2 posts since Mar 2011
Reputation Points: 10
Solved Threads: 0
 

The error means unexpected termination of a string, in case you were unclear about this. It often comes up because a line before the one listed has a problem, if that line doesn't end in a ; or if you have unmatched quotes etc on that line. It can take a while to work out what the cause is, but in this case I really can't see the problem, so my advice is to first take out the blank line above the function, then retype the first couple of lines. It's possible there is some glitch due to an invisible character on one of them.

If you're using a word processor to prepare your code, stop right now and start using a proper editor, or you will continue to get these problems for the rest of your life.

tiggsy
Junior Poster
119 posts since Jul 2009
Reputation Points: 16
Solved Threads: 8
 

Thanks for your reply. I deleted the second line and uploaded the file. the problem still persist. i am using wordpad as editor. If there is an invisible code how can i know about it. and how can i get rid of it.thanks for your reply again.

kunal_28parikh
Newbie Poster
2 posts since Mar 2011
Reputation Points: 10
Solved Threads: 0
 

I just copied your code, and I am not getting the same problem. However I am getting an error (probably because you only pasted in some sample code): Fatal error: Call to undefined function add_action() in /home/public_html/temp.php on line 122

If you're still getting the line 2 error, suggest you retype the line, as I originally suggested.

tiggsy
Junior Poster
119 posts since Jul 2009
Reputation Points: 16
Solved Threads: 8
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: