Reply
Trouble creating a MySQL Table..
Old 05-22-2006, 03:31 PM Trouble creating a MySQL Table..
Novice Talker

Posts: 8
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.

Quote:
<?

$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!");

?>
virtuexru is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 05-22-2006, 04:10 PM Re: Trouble creating a MySQL Table..
Novice Talker

Posts: 8
OK, well I figured something out, I changed the

Quote:
mysql_query($query);
echo("Success!");
to

Quote:
$result = mysql_query($query);
if($result)
echo "Success!";
else
echo "There was an error!" . mysql_error();
but then I got..

Quote:
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
virtuexru is offline
Reply With Quote
View Public Profile
 
Old 05-22-2006, 04:28 PM Re: Trouble creating a MySQL Table..
chrishirst's Avatar
Super Moderator

Latest Blog Post:
Am I impressed or what?
Posts: 14,831
Location: Blackpool. UK
column names cannot contain spaces
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 05-22-2006, 04:32 PM Re: Trouble creating a MySQL Table..
Novice Talker

Posts: 8
Ah I feel like an idiot, but what do you mean? I tried this: but I still got the same error..

Quote:
$user="andiamop";
$password="1200baud";
$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,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))";
$result = mysql_query($query);
if($result)
echo "Success!";
else
echo "There was an error!" . mysql_error();
?>
virtuexru is offline
Reply With Quote
View Public Profile
 
Old 05-22-2006, 04:38 PM Re: Trouble creating a MySQL Table..
chrishirst's Avatar
Super Moderator

Latest Blog Post:
Am I impressed or what?
Posts: 14,831
Location: Blackpool. UK
sorry mis read the list

text fields don't have a size parameter so you cannot have text(nnn)
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 05-22-2006, 04:41 PM Re: Trouble creating a MySQL Table..
Novice Talker

Posts: 8
Ah! Freakin' amazing. Thanks a lot.
virtuexru is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Trouble creating a MySQL Table..
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.13125 seconds with 12 queries