SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Member
    Join Date
    Feb 2006
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up Simple PHP Problem

    PHP Code:
    <?php 

    if ($monthly == "")

    {echo 
    ""<td width="20%">
    <
    div align="center" class="white">"
    "
    .$currency$tenslots."</div></td>"" ;}

     ?>
    Outputs

    Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' on line 75

    Any help would be much appreciated.

    Kind Regards,

    Richard

  2. #2
    SitePoint Addict
    Join Date
    Aug 2004
    Location
    California
    Posts
    267
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by richard1 View Post
    PHP Code:
    <?php 

    if ($monthly == "")

    {echo 
    ""<td width="20%">
    <
    div align="center" class="white">"
    "
    .$currency$tenslots."</div></td>"" ;}

     ?>
    Outputs

    Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' on line 75

    Any help would be much appreciated.

    Kind Regards,

    Richard
    You've got two double quotes at the start of the string. After that you won't be entering a string anymore, which is why PHP is getting confused.

    Try something like this:

    PHP Code:
    <?php 

    if ($monthly == "")

    {echo 
    "<td width=\"20%\">
    <div align=\"center\" class=\"white\">"
    .$currency$tenslots."</div></td>" ;}

     
    ?>
    The Banana Stand - an Arrested Development fansite
    LC-3 Help - tutorials on the LC-3 educational assembly language

  3. #3
    SitePoint Enthusiast
    Join Date
    Feb 2007
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re:SImple PHP Problem

    Check your double quotes Make sure every open double quote is matched with a closing double quote. I noticed you have 13 double quotes; they must be an even number of them.

  4. #4
    SitePoint Wizard Rick's Avatar
    Join Date
    Oct 2002
    Location
    Lancashire, UK
    Posts
    3,847
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    One of the things that makes PHP so flexible for webpages is how easy it is to jump from PHP to HTML. Rather than using lots of echo, try this - it makes the a little cleaner...
    PHP Code:
     <?php 

    if ( !$monthly ) {

    ?>

    <td width="20%">
      <div align="center" class="white">
        <?php echo $currency$tenslots?>
      </div>
    </td>

    <?php

    }

    //page carries on...

    ?>
    Rick

  5. #5
    SitePoint Evangelist superuser2's Avatar
    Join Date
    Aug 2006
    Posts
    598
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I agree with Rick. So much easier then keeping track of escaping and quotes and all that.

  6. #6
    SitePoint Member
    Join Date
    Feb 2006
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Many thanks to everyone who has taken the time to help. However I have reached another problem with the following code:

    PHP Code:
     <?php if ($displaypackagestatus =="2"
          { 
    ?>
          <a href="https://www.domain.com/order/orderwiz.php?v=
          <?php } echo $group_id 
          
    ?>&amp;submit_domain=skip&amp;aid=&amp;c_code=&amp;submit_package=package&amp;type3_package=&amp;type3_package=
          <?php } echo $package_id 
          
    ?>&amp;submit=next+&gt;&gt;"/>
          <?php } else {echo "";} ;?>
    Any help once again is much appreciated.

    Kind Regards,

    Richard

  7. #7
    Who turned the lights out !! Mandes's Avatar
    Join Date
    May 2005
    Location
    S.W. France
    Posts
    2,496
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Try

    PHP Code:
    <?php if ($displaypackagestatus =="2"){ ?> 
     <a href="https://www.domain.com/order/orderwiz.php?
         v=<?php echo $group_id ;?>&amp;submit_domain=skip&amp;aid=&amp;c_code=&amp;submit_package=package&amp;type3_package=<?php echo $package_id ?>&amp;submit=next+&gt;&gt;"/> 
    <?php } else {echo "";} ?>
    you have no value for c_code in the URL !!!

    also you had type3_package listed twice

    but your main problem was your use of curly brackets { }
    A Little Knowledge Is A Very Dangerous Thing.......
    That Makes Me A Lethal Weapon !!!!!!!!

    Contract PHP Programming

  8. #8
    SitePoint Evangelist superuser2's Avatar
    Join Date
    Aug 2006
    Posts
    598
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by richard1
    However I have reached another problem with the following code:
    What problem? Give us the error.

  9. #9
    SitePoint Member
    Join Date
    Feb 2006
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Works like a charm many thanks once again.

    Richard

  10. #10
    Who turned the lights out !! Mandes's Avatar
    Join Date
    May 2005
    Location
    S.W. France
    Posts
    2,496
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by richard1 View Post
    Works like a charm many thanks once again.

    Richard


    Your use of {}'s were breaking the if else structure in PHP
    A Little Knowledge Is A Very Dangerous Thing.......
    That Makes Me A Lethal Weapon !!!!!!!!

    Contract PHP Programming


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •