...

View Full Version : SQL create table?



rafiki
03-08-2007, 06:21 PM
`username` varchar(30) NOT NULL ,
`password` varchar(30) NOT NULL '',
`name` varchar NOT NULL,
`surname` varchar(30) NOT NULL,
`email` varchar(30) NOT NULL ,
PRIMARY KEY (`username`)
should i be using tinytext i read the post on how to choose field types and got confused, does VARCHAR(30) have to be 30 chars long? and i cannot seem to create a table with the following code! any help?

mysql_query("CREATE TABLE users(
`username` varchar(30) NOT NULL ,
`password` varchar(30) NOT NULL '',
`name` varchar NOT NULL,
`surname` varchar(30) NOT NULL,
`email` varchar(30) NOT NULL ,
PRIMARY KEY (`username`)) )";

guelphdad
03-08-2007, 07:38 PM
the error is the ' ' after the password field. Why have a field be NOT NULL if you are going to allow it to have a blank field as the default?

Also when you set a default you need to specify it like this:

password varchar(30) NOT NULL DEFAULT ' '

but again, I'd not have a default of ' '

also in my opinion, make it 40 characters and look into the use of SHA1 for hashing your passwords.

rafiki
03-08-2007, 07:44 PM
mysql_query("CREATE TABLE users(
`username` varchar(30) NOT NULL,
`password` varchar(40) NOT NULL,
`name` varchar NOT NULL,
`surname` varchar(30) NOT NULL,
`email` varchar(30) NOT NULL,
PRIMARY KEY (`username`)) )";
so that should and i quote SHOULD create a mysql table called users
this gave me the error

Parse error: parse error, unexpected ';' in /home/www/rafiki.freehostia.com/jamiewestrunonce.php on line 11

shyam
03-08-2007, 07:51 PM
mysql_query("CREATE TABLE users(
`username` varchar(30) NOT NULL,
`password` varchar(40) NOT NULL,
`name` varchar NOT NULL,
`surname` varchar(30) NOT NULL,
`email` varchar(30) NOT NULL,
PRIMARY KEY (`username`)) )";
so that should and i quote SHOULD create a mysql table called users
this gave me the error

Parse error: parse error, unexpected ';' in /home/www/rafiki.freehostia.com/jamiewestrunonce.php on line 11

using an editor with syntax highlighting should have caught that ;)


mysql_query("CREATE TABLE users(
`username` varchar(30) NOT NULL,
`password` varchar(40) NOT NULL,
`name` varchar NOT NULL,
`surname` varchar(30) NOT NULL,
`email` varchar(30) NOT NULL,
PRIMARY KEY (`username`))");

guelphdad
03-08-2007, 07:57 PM
if you ask me, use something like PHPMYADMIN or HEIDI SQL to create your tables and don't rely on wrapping your sql code in php and making simple syntax errors that have nothing to do with your sql.

rafiki
03-08-2007, 11:14 PM
my host is freehostia.com (using free host) i dont think i have PHPMYADMIN for an option but and i use standard notepad.exe free with windows. Also im waiting for a few parts to come before my "real" pc is up and running, this isnt worth installing a syntax highlighting editor on
but thanks for the help

also i ran the page it said the table hd been created, i get this error

Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /home/www/rafiki.freehostia.com/register.php on line 34
Table '***********.users' doesn't exist

guelphdad
03-09-2007, 12:43 AM
Download EditPlus or some other editor that will highlight your syntax.

also note that when posting here you can wrap your php in these tags [ php] and [/php] without the space in the first tag. that will show you the highlighting as well.

how are you interfacing mysql do you have direct access to it? you should NOT be using php, perl or anything else if you do not have to UNTIL you know that your queries are working correctly. At that point then introduce your application code. Then you will know if the error is mysql or other code related.

rafiki
03-09-2007, 02:25 AM
also note that when posting here you can wrap your php in these tags [ php] and [/php] without the space in the first tag. that will show you the highlighting as well.

how are you interfacing mysql do you have direct access to it? you should NOT be using php, perl or anything else if you do not have to UNTIL you know that your queries are working correctly
currently i am accessing and querying the databse threw PHP as far as i know its the only way with freehostia's free package, and i do know about the php tags for colour syntax but i didnt think it would matter, in future i will use colour highlighting editors is the one you mentioned free?

Nightfire
03-09-2007, 02:26 AM
You can also use scite (www.scintilla.org) I've used it for years and is free

rafiki
03-09-2007, 02:54 AM
You can also use scite (www.scintilla.org (http://www.scintilla.org)) I've used it for years and is free
it says i need a compiler and stuff :/ sorry not for me, this is my spare (real old) pc and looking for .exe to just run and install for me

guelphdad
03-09-2007, 03:58 AM
editplus is free and will install simply. and the tags used here at codingforum are even simpler and will also show your syntax errors.

GJay
03-09-2007, 08:01 AM
http://scintilla.sourceforge.net/SciTEDownload.html includes a link to a windows executable...

(this was linked to from the previous url)

rafiki
03-09-2007, 12:14 PM
http://scintilla.sourceforge.net/SciTEDownload.html includes a link to a windows executable...

(this was linked to from the previous url)
i only managed to find the zip file, also if i just used the php tags here on cf, i would be classed as a spammer right? or are u saying make the thread then delete it :s

Nightfire
03-09-2007, 01:08 PM
http://users.hfx.eastlink.ca/~gisdev/scite-1.70-setup-1.exe direct link to it with all extensions and stuff
http://gisdeveloper.tripod.com/scite.html

guelphdad
03-09-2007, 02:08 PM
i only managed to find the zip file, also if i just used the php tags here on cf, i would be classed as a spammer right? or are u saying make the thread then delete it :s
NO, I'm saying if you have a problem and you post it here and leave it as is but use the php tags you will see the syntax.

Though I'm not sure why you are hesitant to download editplus to your machine. :confused:

rafiki
03-09-2007, 05:37 PM
i not hesitant i would've downloaded it but i followed the link supllied above and installed that one



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum