Support » Fixing WordPress » unexpected T_STRING, expecting ',' or ';'

  • Resolved Micbow

    (@micbow)


    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.]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator Andrew Nevins

    (@anevins)

    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;

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

    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>'; }
    ?>

    esmi

    (@esmi)

    Forum Moderator

    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.

    Thanks esmi that worked spot on.
    Much appreciated

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘unexpected T_STRING, expecting ',' or ';'’ is closed to new replies.