Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Aug 2002
    Posts
    151
    Thanks
    5
    Thanked 0 Times in 0 Posts

    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

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,978
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    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.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #3
    Regular Coder
    Join Date
    Aug 2002
    Posts
    151
    Thanks
    5
    Thanked 0 Times in 0 Posts
    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>';}

  • #4
    Senior Coder djm0219's Avatar
    Join Date
    Aug 2003
    Location
    Wake Forest, North Carolina
    Posts
    1,285
    Thanks
    4
    Thanked 201 Times in 198 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •