Jump to content

[SOLVED] unexpected T_STRING


xProteuSx

Recommended Posts

I know that this is some stupid little mistake that anyone with any knowledge will fix in approximately 3 seconds, but I am a total n00b when it comes to PHP and MySQL.  I can't figure this out.  I am trying to make a table using the following code:

[code]
<?php

$sql = CREATE TABLE users (

'users_id' int(6) NOT NULL auto_increment,
'users_handle' varchar(20) default NULL,
'users_password' varchar (20) default NULL,
'users_email' varchar (40) default NULL,
'users_datejoined' timestamp NOT NULL,
'users_visits' int (6) default '0',
'users_lastvisit' timestamp NOT NULL,
'users_questionsanswered' int(6) default '0',
'users_correctanswers' int(6) default '0',
'users_percentcorrect' float (3,2) default '0',
'users_totalscore' default '0',
'users_pagesviewed' int(8) default '0',
'users_visitbonus' int(6) default '0',
'users_activity' int(6) default '0',
PRIMARY KEY('users_id'),
UNIQUE('users_handle')

) TYPE=MYISAM;
?>
[/code]

I get the following error:  "Parse error: syntax error, unexpected T_STRING in /home/digitalp/public_html/test/mysite/mysqlconnect.php on line 19."  That is the line that states $sql = CREATE TABLE users (

Thanks in advance.
Link to comment
Share on other sites

I am somewhat of a new user to with regards to PHP and MySQL but when creating a statement like that do you not need double quotes around the whole thing? For example:

[code]
<?php

$sql = "CREATE TABLE users ( ".
        "'users_id' int(6) NOT NULL auto_increment, ".
        "....(rest of code)..... ".
        "UNIQUE('users_handle') ".
        ") TYPE=MYISAM;";
?>
[/code]
Link to comment
Share on other sites

After trying single and double quotes all over the place, the following seems to have worked:

[code]
$sql = "CREATE TABLE users (

'users_id' int(6) NOT NULL auto_increment,
'users_handle' varchar(20) default NULL,
'users_password' varchar (20) default NULL,
'users_email' varchar (40) default NULL,
'users_datejoined' timestamp NOT NULL,
'users_visits' int (6) default '0',
'users_lastvisit' timestamp NOT NULL,
'users_questionsanswered' int(6) default '0',
'users_correctanswers' int(6) default '0',
'users_percentcorrect' float (3,2) default '0',
'users_totalscore' default '0',
'users_pagesviewed' int(8) default '0',
'users_visitbonus' int(6) default '0',
'users_activity' int(6) default '0',
PRIMARY KEY('users_id'),
UNIQUE('users_handle')

) TYPE=MYISAM;"
[/code]

Thanks ...
Link to comment
Share on other sites

[quote author=xProteuSx link=topic=114424.msg465588#msg465588 date=1163104924]
I am not sure what you are showing.  You have double quotes and periods all over the place.  You might very well be right, but I am too confused to know where to add all the quotes and the periods.
[/quote]

I didn't really show double quotes and periods all over the place. If you look at the code that I submitted you will notice that for each line a double quote is added to signify a string and at the end of each line there is another double quote followed by a period which signifies the end of a string (double quote) and an indicator that states this string will be appended to the next string (the period).
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.