How to add < href to PHP?

by iisark
2 replies
Hi to all,
I need help with this line of code
$data[1]["Category"]["body"] = str_replace("[!LOCATION!]", $data[2]["Location"]["name"], " ".$data[1]["Category"]["name"]." text text text ".$data[1]["Category"]["name"]." text text text");

I want to add <href link to this line of code (where the "text" words are),so it shoud look something like this:

$data[1]["Category"]["body"] = str_replace("[!LOCATION!]", $data[2]["Location"]["name"], " ".$data[1]["Category"]["name"]." text text LINK GOES HERE text ".$data[1]["Category"]["name"]." text text text");

I added: "LINK GOES HERE" beacuse i 'm not allowed to post links

But when i add the link,my site collapse
Can you please help me with that?
#< #add #href #php
  • Profile picture of the author ussher
    The code you have there looks for ['!LOCATION'] and if it finds that text it replaces it with the value in the $data[2]["Location"]["name"]

    please explain "my site collapse"

    If its a fixed link that doesn't change im guessing that your issue is probably non-escaped quotes.

    the " are stuffing things up because <a href="link to someoehrere">the link</a> has quotes in it.

    Try using single quotes ' or escaping them with a backslash (depending on what language it is)
    <a href=\"link to someoehrere\">the link</a>
    Signature

    "Jamroom is a Profile Centric CMS system suitable as a development framework for building entire communities. Highly modular in concept. Suitable for enterprise level development teams or solo freelancers."

    - jamroom.net
    Download Jamroom free: Download
    {{ DiscussionBoard.errors[5158682].message }}
  • Profile picture of the author rainso0
    Yes. There are many ways. One of them is:

    <html>
    <?php
    echo '<b>' . htmlspecialchars( $name ) . '</b>,<br />';
    echo 'Sorry there's a problem sending your message. ';
    echo 'Please <a href="/mail.html">try again</a>.';
    ?>
    </html>

    another:

    <html>
    <b><?php htmlspecialchars( $name ); ?></b>,<br />
    Sorry there's a problem sending your message.
    Please <a href="/mail.html">try again</a>.
    </html>
    {{ DiscussionBoard.errors[5159949].message }}

Trending Topics