Xtremer360 Posted August 22, 2011 Share Posted August 22, 2011 I'm getting an unexpected t_string and I'm not sure where on this line I'm missing it. <?php echo "<img src=\".base_url()."assets/images/avatar.jpg\".$data->avatar_file."" alt=\"\" />"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/245438-unexpected-t_string/ Share on other sites More sharing options...
JasonLewis Posted August 22, 2011 Share Posted August 22, 2011 Are you using a syntax highlighter? You can see your problem above. My general rule of thumb is to use single quotes whenever possible. echo '<img src="' . base_url() . 'assets/images/avatar.jpg" alt="" />'; I removed the $data->avatar_file, not really sure what you want done with that? Basically, you were escaping your quotes but that buggered up your concatenation. You needed an extra quote, here is an example of how you'd do it how you were trying to: echo "<img src=\"" .base_url() . "assets/images/avatar.jpg\" alt=\"\" />"; I still prefer the single quotes method though, that way you don't need to escape your double quotes. Quote Link to comment https://forums.phpfreaks.com/topic/245438-unexpected-t_string/#findComment-1260579 Share on other sites More sharing options...
Xtremer360 Posted August 22, 2011 Author Share Posted August 22, 2011 Well I didn't notice I had the avatar.jpg part in there but its going to have the users avatar in there so I tried this and I'm still getting the syntax error: <?php echo "<img src=\"" .base_url() . "assets/images/".$data->avatar_file."\" alt=\"\" />"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/245438-unexpected-t_string/#findComment-1260588 Share on other sites More sharing options...
Maq Posted August 22, 2011 Share Posted August 22, 2011 Or something slightly different: echo "avatar_file}' alt='' />"; EDIT: Your new code: echo "avatar_file}' alt='' />"; Quote Link to comment https://forums.phpfreaks.com/topic/245438-unexpected-t_string/#findComment-1260591 Share on other sites More sharing options...
Xtremer360 Posted August 22, 2011 Author Share Posted August 22, 2011 I'm an idiot the line before didn't have the ending "; Quote Link to comment https://forums.phpfreaks.com/topic/245438-unexpected-t_string/#findComment-1260593 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.