Jump to content

Archived

This topic is now archived and is closed to further replies.

virtuexru

Trouble creating a MYSQL Form..

Recommended Posts

This is my first post here so, hopefully I will get some good responses. I have no idea why this table just does not come up on my Database table list. I have tried loads of things, any suggestions? It's probably some stupid error I'm missing.

Thanks a lot.

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]<?

$user="****";
$password="****";
$database="mydb";

mysql_connect(localhost,$user,$password);

@mysql_select_db($database) or die( "Unable to select database");

$query="CREATE TABLE joborder

(id int(6) NOT NULL auto_increment,
title varchar(25) NOT NULL,
number varchar(15) NOT NULL,
desc text(200) NOT NULL,
category varchar(20) NOT NULL,
salary varchar(10) NOT NULL,
addcomp varchar(20) NOT NULL,
position varchar(20) NOT NULL,
location varchar(20) NOT NULL,
details text(350) NOT NULL,
PRIMARY KEY (id),
UNIQUE id (id),
KEY id_2 (id))";

mysql_query($query);
echo("Success!");

?>[/quote]

Share this post


Link to post
Share on other sites
Change:
[code]mysql_query($query);
echo("Success!");[/code]
To:
[code]$result = mysql_query($query);
if($result)
   echo "Success!";
else
   echo "There was an error!" . mysql_error();[/code]

And tell us what you get. It would also help if you had access to phpmyadmin and you could create the table through there (or at least run the SQL through there) and see if you get anything.

Share this post


Link to post
Share on other sites
OK, did that, then I got this error:

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]There was an error!You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'desc text(200) NOT NULL, category varchar(20) NOT NULL, sal [/quote]

Share this post


Link to post
Share on other sites
Here are the errors from MySQL:

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]SQL query:

CREATE TABLE joborder(

id int( 6 ) NOT NULL AUTO_INCREMENT ,
title varchar( 25 ) NOT NULL ,
number varchar( 15 ) NOT NULL ,
description text( 200 ) NOT NULL ,
category varchar( 20 ) NOT NULL ,
salary varchar( 10 ) NOT NULL ,
addcomp varchar( 20 ) NOT NULL ,
position varchar( 20 ) NOT NULL ,
location varchar( 20 ) NOT NULL ,
details text( 350 ) NOT NULL ,
PRIMARY KEY ( id ) ,
UNIQUE id( id ) ,
KEY id_2( id )
)

MySQL said:

#1064 - You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '(200) NOT NULL,category varchar(20) NOT NULL,salary varchar(10) [/quote]

[b]Figured it out, can't define a TEXT field with a number value![/b]

Share this post


Link to post
Share on other sites
Well the first one probably came from the fact that you were using "desc" as a column name... that's a keyword.

I'm not sure what the second error is from.

Share this post


Link to post
Share on other sites

×

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.