Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-15-2013, 05:19 PM   PM User | #1
neodjandre
Regular Coder

 
Join Date: Aug 2002
Posts: 145
Thanks: 5
Thanked 0 Times in 0 Posts
neodjandre is an unknown quantity at this point
Incorrect PHP Syntax

There is something wrong with my PHP syntax but if can't figure this out.. i am such a newb

any help?

Code:
<?php $file = get_field('fl_map_id');if(trim($file) != ""){echo '<a class="colorboxiash" href="'http://www.domain.com/wp-content/plugins/leaflet-maps-marker/leaflet-fullscreen.php?marker=' . $file '">'  . '<img src="http://www.domain.com/images/map.png" alt="map" />' . Map . '</a>';} ?>
many thanks
Andy
neodjandre is offline   Reply With Quote
Old 02-15-2013, 05:33 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,639
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
PHP Code:
<?php $file get_field('fl_map_id');if(trim($file) != ""){echo '<a class="colorboxiash" href="'http://www.domain.com/wp-content/plugins/leaflet-maps-marker/leaflet-fullscreen.php?marker=' . $file '">'  . '<img src="http://www.domain.com/images/map.png" alt="map" />' . Map . '</a>';} ?>
Yep, if you had used PHP tags you'd see that you have an error with the quotes on the href leaving http: hanging, and the rest of the line as a comment. http: itself is invalid in context as it doesn't match a valid constant name, as well as the missing ending } from being commented.
Also a fantastic reason to not put everything on a single line.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
Fou-Lu is offline   Reply With Quote
Old 02-16-2013, 04:28 PM   PM User | #3
neodjandre
Regular Coder

 
Join Date: Aug 2002
Posts: 145
Thanks: 5
Thanked 0 Times in 0 Posts
neodjandre is an unknown quantity at this point
still doesn't work.. I am now using this syntax and getting this error:

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';'

Code:
$file = get_field('fl_map_id');if(trim($file) != ""){echo '<a class="colorboxiash" href="'http://www.domain.com/wp-content/plugins/leaflet-maps-marker/leaflet-fullscreen.php?marker=' . $file .'">'  . '<img src="http://www.domain.com/images/map.png" alt="map" />' . Map . '</a>';}
neodjandre is offline   Reply With Quote
Old 02-16-2013, 07:08 PM   PM User | #4
djm0219
Senior Coder

 
djm0219's Avatar
 
Join Date: Aug 2003
Location: Wake Forest, North Carolina
Posts: 1,227
Thanks: 2
Thanked 189 Times in 187 Posts
djm0219 is on a distinguished road
Quote:
Originally Posted by neodjandre View Post
PHP Code:
$file get_field('fl_map_id');if(trim($file) != ""){echo '<a class="colorboxiash" href="'http://www.domain.com/wp-content/plugins/leaflet-maps-marker/leaflet-fullscreen.php?marker=' . $file .'">'  . '<img src="http://www.domain.com/images/map.png" alt="map" />' . Map . '</a>';} 
If you use the PHP tags you'd be able to see the error quite easily.

PHP Code:
$file get_field('fl_map_id');
if(
trim($file) != ""){
echo 
'<a class="colorboxiash" href="http://www.domain.com/wp-content/plugins/leaflet-maps-marker/leaflet-fullscreen.php?marker=' $file .'"><img src="http://www.domain.com/images/map.png" alt="map" />' Map '</a>';

Also, the Map looks like it may be a variable which means it should be $Map instead of just Map. Hard to tell from what you posted whether or not that's the case.
__________________
Dave .... HostMonster for all of your hosting needs
djm0219 is online now   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:37 PM.


Advertisement
Log in to turn off these ads.