php syntax... where did I screw up?

Discussion in 'OT Technology' started by JEWbacca, Apr 9, 2005.

  1. JEWbacca

    JEWbacca =/

    Joined:
    May 10, 2001
    Messages:
    2,230
    Likes Received:
    0
    Location:
    Long Beach, CA
    I'm trying to customize a greeting for an osCommerce site, but somewhere I fucked up on the php. Any ideas?

    Code:
    
    define('TEXT_GREETING_PERSONAL', '<small><td valign="top"><div align="center">
                      <table width="517" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                          <td valign="top"><img src="http://blackwidowsecurity.com/images/titlebar.jpg" alt="Black Widow Security Systems" width="517" height="24"></td>
         </tr>
                        <tr>
                          <td valign="top" background="http://blackwidowsecurity.com/images/mainc_background.jpg"><table width="517" border="0" cellspacing="0" cellpadding="5">
                            <tr>
                              <td align="left">
    Welcome back <span class="greetUser">%s</span> to the Black Widow Online Store! You are of a vauled member of our echo '$sppc_customer_group_id'; group.
    }
    <br><br>
    if ($sppc_customer_group_id != '1')
    {
    echo 'Although on line sales of Black Widow systems are limited to authorized dealers only, the Black Widow on line Store does offer our complete line of accessories, including replacement transmitters, that are available to everyone.';
    } else {
    echo 'On line sales of Black Widow systems are available to you as an authorized dealer as well as our complete line of accessories priced lower than you can find them anywhere else!';
    <br><br>
    if ($sppc_customer_group_id != '1')
    {
    echo 'Black Widow\'s on line store excepts all major credit cards and Paypal for purchases. ';
    } else {
    echo 'Black Widow\'s on line store excepts all major credit cards and Paypal for purchases, but as an Authorized Black Widow dealer or distributor, you may choose from these payment options or opt to apply your pre-existing sales terms provided by Black Widow\'s credit department.';
    }
    <br><br>
    Thank you for visiting our store, we hope it makes your life easier!  Of course if you prefer to place your orders with a live sales associate, please feel free to drop us a line during our normal business hours. <br><br>
         </tr>
                          </table></td>
                        </tr>
                        <tr>
                          <td valign="top"><img src="http://blackwidowsecurity.com/images/mainc_bottom.jpg" width="517" height="7"></td>
                        </tr>
                      </table>');
    define('TEXT_GREETING_GUEST', '<small><td valign="top"><div align="center">
                      <table width="517" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                          <td valign="top"><img src="http://blackwidowsecurity.com/images/titlebar.jpg" alt="Black Widow Security Systems"
    
    width="517" height="24"></td>
         </tr>
                        <tr>
                          <td valign="top" background="http://blackwidowsecurity.com/images/mainc_background.jpg"><table width="517"
    
    border="0" cellspacing="0" cellpadding="5">
                            <tr>
                              <td align="left">
    Welcome to the Black Widow Online Store, your online home for vehicle security products!<br><br>
    
    We understand that oftentimes there are just not enough hours in the day to get everything done.  That\'s why we\'ve created the Black Widow Online Store- a 24 hour a day, 7 day a week business resource that enables you to view products, download manuals, and place orders all at a time that is most convenient for you!<br><br>
    
    Please take a moment and <a href="http://blackwidowsecurity.com/store/create_account.php"><u>register</u></a>
    your email address to receive a personal login and password.  Once you have registered and <a href="http://blackwidowsecurity.com/store/login.php"><u>logged
    in</u></a>, you will be able to view exclusive pricing on all items within the Black Widow website.
                            </tr>
                          </table></td>
                        </tr>
                        <tr>
                          <td valign="top"><img src="http://blackwidowsecurity.com/images/mainc_bottom.jpg" width="517" height="7"></td>
                        </tr>
                      </table>');
    
     
  2. kingtoad

    kingtoad OT Supporter

    Joined:
    Sep 2, 2003
    Messages:
    55,918
    Likes Received:
    10
    Location:
    Los Angeles
    That is some very messy code. :o

    There is a number of problems with your code. The majority of the problems consist of your single quotations and double quotations. In your define() statement, 2nd argument, you use a single quotation to begin the value, which in this case is all the HTML code. However, on line 11, you are echo'ing $sppc_customer_group_id with a single quote, which will END the 2nd input of your define() function, because you started it with a quotation. If you take that out, it will complain about the If/else statements, because again... you use single quotations to accomplish the comparisons of your switch statements. Line 12 will complain about an extra curely bracket, and there are double quotations all over the place, which you will have to catinate to use in this function. The best way to accomplish what you are trying to do is write a function that outputs all of HTML and call the function in the define statement. I wouldn't do it that way myself though. I don't think I've ever used the define function before. :o
     
  3. PocoDiablo

    PocoDiablo New Member

    Joined:
    Jul 11, 2004
    Messages:
    4,413
    Likes Received:
    0
    Location:
    NOVA
    Here's a tip for troubleshooting code:

    Remove half the code, then run it. If there is an error, then you know it's not in the code you removed.

    Replace the code and remove the other 50% of the code. Same as above. Then you can start removing 5-10 lines at a time. Once the error ceases, you know which line it is in. ;)
     
  4. Slid.

    Slid. I'm a guy.

    Joined:
    Oct 25, 2001
    Messages:
    1,928
    Likes Received:
    0
    Location:
    NH
    If you are still having trouble with it post in here and I'll fix it -- it is pretty chaotic but I can see some obvious errors.
     

Share This Page