1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

unexpected T_STRING ???

Discussion in 'PHP' started by SamPit, Mar 4, 2008.

  1. #1
    Hello could you help me someone
    I am a newbie so please don't flame me:(

    I got an error: Parse error: syntax error, unexpected T_STRING in /home/xxx/public_html/xxxxxx.php on line 8

    here is the line 8

    $fname = mysql_query(SELECT FName FROM members WHERE Username=$username)
    PHP:
    Thanks
    Sam
     
    SamPit, Mar 4, 2008 IP
  2. roy.laurie

    roy.laurie Peon

    Messages:
    51
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    $fname = mysql_query("SELECT FName FROM members WHERE Username='$username'");
    PHP:
    Make sure to escape $username before you execute that query.

    $username = mysql_escape_string($username);
    PHP:
     
    roy.laurie, Mar 4, 2008 IP
  3. SamPit

    SamPit Peon

    Messages:
    185
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I did but I still got the same error:(
     
    SamPit, Mar 4, 2008 IP
  4. roy.laurie

    roy.laurie Peon

    Messages:
    51
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    How about the semi-colon at the end? Also, look for a missing semi-colon above that line, too.
     
    roy.laurie, Mar 4, 2008 IP
    SamPit likes this.
  5. SamPit

    SamPit Peon

    Messages:
    185
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #5

    here is the code before:

    <?php
    session_start();
    $username = $_SESSION[MM_Username];
    ?>
    <?php
    mysql_connect("localhost", ":p:p:p:p:p:p", ":p:p:p:p:p");
    mysql_select_db("members") or die(mysql_error());
    
    $fname = mysql_query(SELECT FName FROM members WHERE Username=$username);
    
    mysql_close();
    ?>
    PHP:
    help me please
     
    SamPit, Mar 4, 2008 IP
  6. Morishani

    Morishani Peon

    Messages:
    239
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Even if your code will work, $fname will not recieve the Fname from the function mysql_query,

    Check out this page for a better example : http://il2.php.net/manual/en/function.mysql-query.php

    Good luck
     
    Morishani, Mar 4, 2008 IP
    SamPit likes this.
  7. SamPit

    SamPit Peon

    Messages:
    185
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Thank you all
    Rep added
    But I just found something in Deamweaver that do all this work for me
     
    SamPit, Mar 5, 2008 IP