Give help. Get help.

  • # January 16, 2013 at 7:07 am


    How do I write this code inside PHP echo ” “;

    < ?php
    echo “


    I tried writing it just like the above code but it doesn’t work.

    # January 16, 2013 at 7:30 am

    Need to add a ; to the end of your echo after the closing quote mark.

    # January 16, 2013 at 10:24 am

    just so you know, this:

    < ?php
    echo “

    < .img src='images/linkedin-icon.png' onMouseDown='document.images['large'].src='images/linkedin.png' ' />
    < .img src='images/facebook-icon.png' onMouseDown='document.images['large'].src='images/facebook.png' ' />
    < .img src=' ' name='large'>

    ” ;

    and this:

    < ?php
    < .img src='images/linkedin-icon.png' onMouseDown='document.images['large'].src='images/linkedin.png' ' />
    < .img src='images/facebook-icon.png' onMouseDown='document.images['large'].src='images/facebook.png' ' />
    < .img src=' ' name='large'>

    are *exactly* equivalent.

    Also, when writing HTML (or anything else that may have quote marks), it’s usually much easier to use the HEREDOC notation:

    $string = < << HTML
    Hello, I’m using “quotes” left and right, and I don’t need to escape them.
    I can still use $variables in my text,
    or even {$nested}.
    A “HEREDOC” is like a “double-quote” string,
    but it starts with three less-than brackets ( < << )
    followed by a token (anything; I used “HTML” here)
    and ends when the token appears at the beginning of a line
    (by itself, no indentation at all),
    with a semicolon by itself on the next line.
    Have a try!

    # January 16, 2013 at 11:07 am

    Try this:

    < ?php if ( is_page_template('template-fullwidth.php') ) { ?>
    your html here
    < ?php } elseif ( is_page_template('template-planes.php') ) { ?>
    your html here
    < ?php } else { ?>
    your html here
    < ?php } ?>

    # January 16, 2013 at 6:13 pm

    Thank you for all your answers ( @Rai, @traq, @AndyHowells ). One problem that I keep on encountering with that code is the pure html works and does swap image but when I try to incorporate it inside PHP, it doesn’t work anymore. That is why i’m looking for a work around on how to write it inside PHP because I will be getting the image source from a database if only those code will work. :( Please help…

    # January 16, 2013 at 7:34 pm

    Well, what do you mean by “doesn’t work”?

    What actually happens vs. what you expected?

    Did you make sure error reporting is enabled, and do you get any error messages?

    # January 16, 2013 at 8:40 pm

    @traq, Sorry if I sound a little confusing. The pure HTML markup with a little javascript I posted does a “swap image”. The small/thumbnail images when clicked , a bigger version of that image will appear below. But then when I try to rewrite the code inside PHP and run it in a browser, it doesn’t do anything when you click the thumbnail image but I didn’t get any error messages.

    # January 16, 2013 at 8:46 pm

    @ajnoguerra what does the output HTML look like?

    # January 16, 2013 at 9:25 pm

    @traq, I’m glad you’re really trying to help me. Here’s the output >>> [swap image]( “simple-swap-image”)

    # January 16, 2013 at 11:52 pm

    > Here’s the output

    That seems to work as expected, unless I misunderstand your problem.

    Are you sure you posted the **output** HTML (i.e., the HTML *that is generated by PHP* and demonstrates your problem)?

    # January 17, 2013 at 9:33 pm

    < ?php
    mysql_connect(“localhost”,”root”,””) or die (mysql_error());
    mysql_select_db(“motoactiv-db”) or die (mysql_error());

    $sql = “Select * FROM products”;
    $result = mysql_query($sql);

    < ?php

    I still haven’t figured out the problem with this because when I tested it out in Firefox and IE it works just fine but when I tried it with Chrome, it doesn’t make the bigger image come out, it is as if no javascript was implemented. @traq

    # January 18, 2013 at 1:28 am

    @ajnoguerra – see my comment in your other thread.

    # January 18, 2013 at 4:19 am


    Why are you escaping the quotes? You don’t need to do that. You only need to do that when the quotes are the same as the surrounding quotes. If your html is inside double quotes, you don’t need to escape single quotes.

    # January 18, 2013 at 4:24 am

    wow such a great info. []( “”)

Viewing 14 posts - 1 through 14 (of 14 total)

You must be logged in to reply to this topic.