Simple php code returning T_STRING error please help

Discussion in 'PHP' started by rushy, Apr 19, 2008.

  1. #1
    <?php
    if ($_GET[’kw’])
    {echo htmlentities($_GET[’kw’]);}
    else
    {echo ucwords(”Your Original Info Here”);}
    ?>
    Code (markup):
    This simple php code returns the T_STRING error. Can anyone give me some pointers as to why this could be happening?

    cheers,
     
    rushy, Apr 19, 2008 IP
  2. phpl33t

    phpl33t Banned

    Messages:
    456
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    0
    #2
    
    <?php
    
    if ($_GET['kw']) {
         echo htmlentities($_GET['kw']);
    } else {
         echo ucwords('Your Original Info Here');
    }
    
    ?>
    
    PHP:
     
    phpl33t, Apr 19, 2008 IP
  3. rushy

    rushy Peon

    Messages:
    251
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Cheers, mate...+ rep

    Noob I am ;-)
     
    rushy, Apr 19, 2008 IP
  4. phpl33t

    phpl33t Banned

    Messages:
    456
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I was at one point too friend:) You are quite welcome. Also, big tip I like to give... Use single quotes so that you can use double quotes in strings without having to backslash. Like this:

    
    
    Bad:
    $var = "My nickname is \"phpl33t\".";
    
    Good:
    $var = 'My nickname is "phpl33t".';
    
    
    or...
    
    
    mysql_query("SELECT * FROM `users` WHERE `username`=\"$username\"") or die(mysql_error());
    
    Good:
    mysql_query('SELECT * FROM `users` WHERE `username`="'.$username.'"') or die(mysql_error());
    
    
    PHP:
     
    phpl33t, Apr 19, 2008 IP