Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

PHP echo single quote breaking echo

Posted on 2011-09-30
5
Medium Priority
?
403 Views
Last Modified: 2012-05-12
I am trying to use a dynamic variable in a Wordpress shortcode in a theme using do_shortcode like this:

<?php echo do_shortcode('[map id="map1" address="<?php echo($row['fulladdress']); ?> <?php echo($row['city']); ?>, <?php echo($row['zip']); ?> " z="15"]'); ?>

Open in new window


That does not work...this does though so I know its my echo statements breaking it because this does work:

<?php echo do_shortcode('[map id="map1" address="Austin, TX " z="15"]'); ?>

Can someone help me figure out how to format this?
0
Comment
Question by:pda4me
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 17

Expert Comment

by:Chris Harte
ID: 36893158
I don't know anything about wordpress or do_shortcode, but I can tell you have a lot of mismatched braces and brackets in there. Do not echo variables or use  php tags inside php tags. That z=15 is just hanging loose on the end of that line. I can not tell what you are trying to do with it. But try this.


$content = '[map id="map1" address="'.$row['fulladdress'].'"';

echo do_shortcode ($content);


echo($row['city']);
echo($row['zip']);
0
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 2000 total points
ID: 36893218
Using echo inside echo seems out of place to me.  And echo is not a function so you can remove the parentheses.

I think you might be looking for something like this, but it is hard to guess:

$str = '[map id="map" address="';
$str .= $row['fulladdress'];
$str .= '"';
$str .= ' ' . $row['city'];
$str .= ' ' . $row['zip'];
$str .= '"'
$str .= '  z="15"]';

echo do_shortCode($str);

It is much easier to get the code right if you do not use compound statements.
0
 

Author Comment

by:pda4me
ID: 36893225
i need the city and zip and the closing bracket ] to finish the short code?  How do I include those?  Nothing I try worked?
0
 

Author Closing Comment

by:pda4me
ID: 36893278
Bingo, thanks Ray!!!
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 36893304
Thanks for the points!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
This article discusses how to implement server side field validation and display customized error messages to the client.
The purpose of this video is to demonstrate how to Import and export files in WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Click on Too…
The purpose of this video is to demonstrate how to set up the permalinks on a WordPress Website. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Go t…
Suggested Courses

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question