WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] unexpected T_STRING, expecting ',' or ';' (6 posts)

  1. Micbow
    Member
    Posted 1 year ago #

    Hi I hope someone can help me please. I think this is an easy fix but I just can't get it right.

    I'm getting the following error:
    Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' on line 24

    <?php  if ( get_post_meta($post->ID, 'phone_number', true)) { echo '<a>ID, 'phone_number', true); ?>" ><div class="alcentre">Tap <?php get_post_meta($post->ID, "phone_number", true); ?> to Call</div></a>'; }
    ?>

    I know it's got to do with the " or ' and I've tried different combinations and adding / but I just can't get it to work.

    Thanks in advance.

    [Moderator Note: Please post code or markup snippets between backticks or use the code button. As it stands, your code has now been permanently damaged/corrupted by the forum's parser.]

  2. Andrew
    Forum Moderator
    Posted 1 year ago #

    On line 24, you're closing a parenthesis never opened.
    You're also forgetting to close the string, "ID".
    Use

    echo 'ID', 'phone_number', true;
  3. Micbow
    Member
    Posted 1 year ago #

    I'm having trouble adding the code to the it keeps changing it standby

  4. Micbow
    Member
    Posted 1 year ago #

    Here's the code here

    <?php  if ( get_post_meta($post->ID, 'phone_number', true)) { echo '<a href="tel:<?php get_post_meta($post->ID, 'phone_number', true); ?>" ><div class="alcentre">Tap <?php get_post_meta($post->ID, "phone_number", true); ?> to Call</div></a>'; }
    ?>
  5. esmi
    Forum Moderator
    Posted 1 year ago #

    Try:

    <?php  if ( get_post_meta($post->ID, 'phone_number', true))
    	echo '<a href="tel: ' . get_post_meta($post->ID, 'phone_number', true) . '" ><div class="alcentre">Tap ' . get_post_meta($post->ID, "phone_number", true) . ' to Call</div></a>';
    ?>

    You don't use <?php or ?> inside an echo statement.

  6. Micbow
    Member
    Posted 1 year ago #

    Thanks esmi that worked spot on.
    Much appreciated

Topic Closed

This topic has been closed to new replies.

About this Topic