Small PHP code problem with Quote marks within Quotes

Discussion in 'PHP' started by misohoni, Jan 31, 2011.

  1. #1
    For example in this PHP code I have:
    else {
    $videourl = "https://bill.ccbill.com/jpost/billingCascade.cgi?clientAccnum=939993&clientSubacc=<?=$set["ccbillsub"]?>&cascadeId=<?=$set["ccbillID"]?>";

    I know the problem is the extra php commands which are messed up in the url:
    <?=$set["ccbillsub"]?>
    <?=$set["ccbillID"]?>

    How best to display them as I'm getting unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING errors.
     
    misohoni, Jan 31, 2011 IP
  2. rainborick

    rainborick Well-Known Member

    Messages:
    424
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    120
    #2
    This should be better:
    
    $videourl = "https://bill.ccbill.com/jpost/billingCascade.cgi?clientAccnum=939993&clientSubacc=" . $set["ccbillsub"] . "&cascadeId=" . $set["ccbillID"];
    
    Code (markup):
     
    rainborick, Jan 31, 2011 IP
  3. Shane-

    Shane- Peon

    Messages:
    25
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You can also use the \ key for your quote marks in strings

    For example:
    echo 'Tizag - It\'s Neat!';
    Code (markup):
     
    Shane-, Jan 31, 2011 IP
  4. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #4
    $videourl = "https://bill.ccbill.com/jpost/billingCascade.cgi?clientAccnum=939993&clientSubacc={$set['ccbillsub']}&cascadeId={$set['ccbillID']}";
    PHP:
     
    danx10, Jan 31, 2011 IP
  5. misohoni

    misohoni Notable Member

    Messages:
    1,717
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    200
    #5
    misohoni, Jan 31, 2011 IP