help needed: php T-String Probs

Discussion in 'PHP' started by thefm, Apr 24, 2010.

  1. #1
    dear all;

    i am developing a website for my company;

    i'm trying to combining php and xml together;

    when i try to run the page, this statement appear:
    Parse error: syntax error, unexpected T_STRING in /home/localhost/dataku.php on line 14


    here is my problem coding according to the number mention in problem above:

    $xml_output .= "<nama>" . "<A XML-LINK="LINK" HREF="".$ourData->web .""/>.$ourData->nama . "</A>"</nama>\n";

    i'm trying to combining my customer name with their website by using above method. But somehow it didn't work!!

    please help me...

    thanks
     
    thefm, Apr 24, 2010 IP
  2. Brad33

    Brad33 Peon

    Messages:
    69
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    $xml_output .= "<nama>" . "<A XML-LINK=\"LINK\" HREF=\"".$ourData->web ."\" />".$ourData->nama."</A>\"</nama>\n";
    PHP:
    That should work for you. You were missing a few backslashes for escaping some quotes, and forgot some quotes around "$ourData->nama".

    Another way it could be done that might look a little cleaner...

    $xml_output .= '<nama><A XML-LINK="LINK" HREF="'.$ourData->web.'" />'.$ourData->nama.'</A>"</nama>'."\n";
    PHP:
    Using single quotes instead of double quotes around your string will allow you to use double quotes inside without escaping, simplifying things a bit. But remember, single quotes won't parse special operators inside the string, that's why at the end I have used double quotes around "\n" so that it is parsed as such.
     
    Last edited: Apr 24, 2010
    Brad33, Apr 24, 2010 IP
  3. thefm

    thefm Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    weeheee..its work!

    thanks so much Brad..u have save my life...;):)
     
    thefm, Apr 24, 2010 IP
  4. Brad33

    Brad33 Peon

    Messages:
    69
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Hey, no problem buddy.

    If you need anything else, just shoot me a PM.

    Have a good one,
    Brad
     
    Brad33, Apr 24, 2010 IP