Jump to content


Photo

Trouble creating a MYSQL Form..


  • Please log in to reply
4 replies to this topic

#1 virtuexru

virtuexru
  • Members
  • PipPipPip
  • Advanced Member
  • 200 posts

Posted 22 May 2006 - 07:03 PM

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]

#2 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 22 May 2006 - 07:08 PM

Change:
mysql_query($query);
echo("Success!");
To:
$result = mysql_query($query);
if($result)
   echo "Success!";
else
   echo "There was an error!" . mysql_error();

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.

Info: PHP Manual


#3 virtuexru

virtuexru
  • Members
  • PipPipPip
  • Advanced Member
  • 200 posts

Posted 22 May 2006 - 07:10 PM

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]

#4 virtuexru

virtuexru
  • Members
  • PipPipPip
  • Advanced Member
  • 200 posts

Posted 22 May 2006 - 07:42 PM

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]

Figured it out, can't define a TEXT field with a number value!

#5 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 22 May 2006 - 07:45 PM

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.

Info: PHP Manual





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users