Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    May 2007
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    I'm getting a T_String Error?

    OK, so I go an "Unexpected T_String Error" and I want to know what I'm doing wrong. I'm still new at this type of thing and am unsure of how to fix it.

    Code:
    <?php
    include 'members/include/session.php';
    include 'members/connect.php';
    
    mysql_select_db('winterdu_members') or die('Cannot select database'); 
    
    $query = 'CREATE TABLE print $_SESSION['username']profile( '.
             'name VARCHAR(50) NOT NULL, '.
             'age VARCHAR(2) NOT NULL, '.
             'citystate VARCHAR(50) NOT NULL, '.
             'country VARCHAR(30) NOT NULL, '.
             'about VARCHAR(5000) NOT NULL, '.
             'music VARCHAR(5000) NOT NULL, '.
             'movies VARCHAR(5000) NOT NULL, '.
             'tv VARCHAR(5000) NOT NULL, '.
             'hobbies VARCHAR(5000) NOT NULL, '.
             'PRIMARY KEY(name))';
    
    $result = mysql_query($query);
    
    ?>
    It says the error is on line 7 which is:

    Code:
    $query = 'CREATE TABLE print $_SESSION['username']profile
    I know that the print $_SESSION part is the problem, but I just don't know how to fix it so that it will work.

    For a little background information, what that would do is create the table "usernameprofile" so if UserA was logged in, the table UserAprofile would be created.

  • #2
    Senior Coder timgolding's Avatar
    Join Date
    Aug 2006
    Location
    Southampton
    Posts
    1,519
    Thanks
    114
    Thanked 110 Times in 109 Posts
    'PRIMARY KEY(name))';
    You can not say you know how to do something, until you can teach it to someone else.

  • #3
    Senior Coder
    Join Date
    Mar 2003
    Location
    Atlanta
    Posts
    1,037
    Thanks
    14
    Thanked 30 Times in 28 Posts
    Actually, its the whole query statement thats giving you problems...
    You have far to many single quotes and you do not have to use (.) to concatenate the end of each line. You can have whitespace and the query will still work.

    PHP Code:
    //these two $query are equal

    $query 'SELECT * FROM [I]table[/I] WHERE id = 1';

    $query 'SELECT * FROM [I]table[/I]




    WHERE id 

    = 1'

    Also I don't understand what you are trying to go for with this line?
    PHP Code:
    'CREATE TABLE print $_SESSION['username']profile( ' 
    Also, depending on your database type (and version), your datatypes may not be valid. Either way, surely they are not optimal.
    Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.

  • #4
    Senior Coder
    Join Date
    Mar 2003
    Location
    Atlanta
    Posts
    1,037
    Thanks
    14
    Thanked 30 Times in 28 Posts
    Wait....are you trying to give every user their OWN table??? If so, lets take a walk back up to the drawing board. What are you trying to accomplish?

    P.S. - you can not use print the way you have it....as you are literally printing the word 'print' same thing with the session variable. Functions (or constructs in this case) will not be executed when inside of a string. Try and echo that statement out and see what you get.
    Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.

  • #5
    New Coder
    Join Date
    May 2007
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by StupidRalph View Post
    Wait....are you trying to give every user their OWN table??? If so, lets take a walk back up to the drawing board. What are you trying to accomplish?

    P.S. - you can not use print the way you have it....as you are literally printing the word 'print' same thing with the session variable. Functions (or constructs in this case) will not be executed when inside of a string. Try and echo that statement out and see what you get.
    Ya, I am definetly going back to the drawing board. These are pure newbie efforts and they sure aren't getting me anywhere


    I'm just trying to make a simple user profile page. And obviously this is not going to be the way to do it.

  • #6
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    One table for all users, use a unique identifier (such as user_id) as your primary key.


  •  

    Posting Permissions

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