Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Syntax Error - Confused

Syntax Error - Confused

Syntax Error - Confused

I am using the following code to create tables within a MySQL database:

CODE -->

// Connect to the database
mysql_connect("$mysql_host","$mysql_username","$mysql_passwd") or die (mysql_error()); 
mysql_select_db("$mysql_dbase") or die (mysql_error());

// Create the tables
mysql_query("CREATE TABLE $redir_table ( host varchar(100) NOT NULL default '', name varchar(25) NOT NULL default '', vname varchar(25) NOT NULL default '', passwd varchar(50) NOT NULL default '', email varchar(100) NOT NULL default '', url varchar(100) NOT NULL default '', title varchar(100) NOT NULL default '', descr text NOT NULL, keyw text NOT NULL, counter int(11) default NULL, robots varchar(50) NOT NULL default '', news char(3) NOT NULL default '', revisit text NOT NULL, time varchar(15) NOT NULL default '', ip varchar(20) NOT NULL default '', cat varchar(50) NOT NULL default '', lasttime varchar(15) NOT NULL default '', stats char(3) NOT NULL default '', mail char(3) NOT NULL default '', adtype varchar(15) NOT NULL default '', acticode varchar(15) NOT NULL default '', active char(3) NOT NULL default '', PRIMARY KEY (host), UNIQUE KEY host (host) )") or die (mysql_error()); 
mysql_query("CREATE TABLE $options_table ( home varchar(50) NOT NULL default '', sitetitle varchar(150) NOT NULL default '', adminemail varchar(50) NOT NULL default '', username varchar(50) NOT NULL default '', password varchar(50) NOT NULL default '', domainip varchar(15) NOT NULL default '', maindomain varchar(50) NOT NULL default '', mailtoadmin char(3) NOT NULL default '', language varchar(20) NOT NULL default '', multiple char(3) NOT NULL default '', minlength char(2) NOT NULL default '', maxlength char(2) NOT NULL default '', reserved text NOT NULL, forbidden text NOT NULL, autoappr char(3) NOT NULL default '', theme varchar(50) NOT NULL default '', release varchar(10) NOT NULL default '' )") or die (mysql_error());
mysql_query("CREATE TABLE $domain_table ( domain varchar(50) NOT NULL default '' )") or die (mysql_error());
mysql_query("CREATE TABLE $category_table ( category varchar(50) NOT NULL default '', advtype varchar(20) NOT NULL default '', adurl varchar(150) NOT NULL default '', height varchar(4) NOT NULL default '', width varchar(4) NOT NULL default '' )") or die (mysql_error());
mysql_query("CREATE TABLE $visitor_table ( host varchar(100) NOT NULL default '', date varchar(15) NOT NULL default '', ip varchar(20) NOT NULL default '', agent varchar(250) NOT NULL default '', ref varchar(250) NOT NULL default '', timestamp varchar(15) NOT NULL default '' )") or die (mysql_error()); 

The database parameters and variables in the top three lines are defined much earlier in my code and are not printed in the above code.

The script connects to the database with no problems. I am receiving the following error when the code creates the database tables:
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 'release varchar(10) NOT NULL default '' )' at line 1

I am using MySQL version 5.5

I would appreciate any help in fixing ALL of the above syntax for this MySQL version.

Thanks so much

RE: Syntax Error - Confused

Print the MySQL query to the browser so you can see the actual concatenated query to locate the error is a debugging tip.

HOWEVER "release" is a reserved word in MySQL so should NOT be used as a column name OR should be enclosed in backticks (different to apostrophes).


Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.

Never mind this jesus character, stars had to die for me to live.

RE: Syntax Error - Confused

Additionally to Chris' advice, consider running troublesome queries in MySQL directly. If you utilize a MySQL GUI frontend tool like MySQL Workbench, SQLyog, HeidiSQL, or many others...the syntax highlighting of your queries may better illustrate where you've jumped off the track...if your PHP editor is not already illustrating the issue with syntax.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close