Connecting Tech Pros Worldwide Forums | Help | Site Map

Create table

Member
 
Join Date: Aug 2007
Posts: 38
#1: Jun 12 '09
My site is being hosted on www.110mb.com
I tried to fallow an online tutorial, but I still get e rrors

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. // Make a MySQL Connection
  3. mysql_connect("localhost", "jpenguin_root", "*******") or die(mysql_error());
  4. mysql_select_db("jpenguin_brain") or die(mysql_error());
  5.  
  6. // Create a MySQL table in the selected database
  7. mysql_query("CREATE TABLE example(
  8. id INT NOT NULL AUTO_INCREMENT, 
  9. PRIMARY KEY(id),
  10.  name VARCHAR(30), 
  11.  time VARCHAR(30), 
  12.  comment VALCHAR(100)")
  13.  or die(mysql_error());  
  14.  
  15. echo "Table Created!";
  16.  
  17. ?>
I get, "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 'VALCHAR(100)' at line 6"

I'm trying to learn about MySQL, that's why I'm not using a GUI tool

prabirchoudhury's Avatar
Familiar Sight
 
Join Date: May 2009
Location: Wellington, New Zealand
Posts: 152
#2: Jun 13 '09

re: Create table


Quote:
mysql_query("CREATE TABLE example(
id INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id),
name VARCHAR(30),
time VARCHAR(30),
comment VALCHAR(100)")
or die(mysql_error());
you have a data type spelling mistake on
Expand|Select|Wrap|Line Numbers
  1. comment VALCHAR(100)"
  2.  
would be
Expand|Select|Wrap|Line Numbers
  1. comment VARCHAR(100)"
  2.  
:))
Member
 
Join Date: Aug 2007
Posts: 38
#3: Jun 13 '09

re: Create table


LOL, I can't believe I did that :-)
prabirchoudhury's Avatar
Familiar Sight
 
Join Date: May 2009
Location: Wellington, New Zealand
Posts: 152
#4: Jun 13 '09

re: Create table


thats happen some time.. :))
Reply