xProteuSx Posted November 9, 2006 Share Posted November 9, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/26722-solved-unexpected-t_string/ Share on other sites More sharing options...
CaptainSlow Posted November 9, 2006 Share Posted November 9, 2006 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] Quote Link to comment https://forums.phpfreaks.com/topic/26722-solved-unexpected-t_string/#findComment-122238 Share on other sites More sharing options...
xProteuSx Posted November 9, 2006 Author Share Posted November 9, 2006 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 Link to comment https://forums.phpfreaks.com/topic/26722-solved-unexpected-t_string/#findComment-122257 Share on other sites More sharing options...
xProteuSx Posted November 9, 2006 Author Share Posted November 9, 2006 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 ... Quote Link to comment https://forums.phpfreaks.com/topic/26722-solved-unexpected-t_string/#findComment-122265 Share on other sites More sharing options...
CaptainSlow Posted November 10, 2006 Share Posted November 10, 2006 [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). Quote Link to comment https://forums.phpfreaks.com/topic/26722-solved-unexpected-t_string/#findComment-122756 Share on other sites More sharing options...
fenway Posted November 10, 2006 Share Posted November 10, 2006 In fact, in your example, you don't need any quotes at all anywhere. Quote Link to comment https://forums.phpfreaks.com/topic/26722-solved-unexpected-t_string/#findComment-122808 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.