...

View Full Version : I'm getting a T_String Error?



winterdude
07-30-2007, 01:41 AM
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.


<?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:


$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.

timgolding
07-30-2007, 01:46 AM
'PRIMARY KEY(name))';

StupidRalph
07-30-2007, 01:54 AM
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.



//these two $query are equal

$query = 'SELECT * FROM table WHERE id = 1';

$query = 'SELECT * FROM table




WHERE id

= 1';

Also I don't understand what you are trying to go for with this line?

'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.

StupidRalph
07-30-2007, 01:59 AM
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.

winterdude
07-30-2007, 02:02 AM
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.

Fumigator
07-30-2007, 03:28 AM
One table for all users, use a unique identifier (such as user_id) as your primary key.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum