Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Query Syntax

Posted on 2015-01-28
2
47 Views
Last Modified: 2015-03-07
I am getting the following Query Syntax error.  Can anyone tell me what I am doing wrong.?  Also, how does the error determine "line 3"?  Meaning, how does it count lines?

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 'UNSIGNED, `markel_serff_tracking` varchar UNSIGNED, `pd_base_rate` decimal UNS' at line 3

Query:
$fields = array(

				'id' => array(
					'type' => 'int',
					'constraint' => '11',
					'unsigned' => TRUE,
					'auto_incriment' => TRUE	
				),
				
				'state' => array(
					'type'=> 'varchar',
					'constraints' => '4',
					'unsigned' => TRUE,
					'auto_incriment' => FALSE
				),
				
				'markel_serff_tracking' => array(
					'type' => 'varchar',
					'constraints' => '150',
					'unsigned' => TRUE,
					'auto_incriment' => FALSE
				),
				
				'pd_base_rate' => array (
					'type' => 'decimal',
					'constraints' => '10,2',
					'unsigned' => TRUE,
					'auto_incriment' => FALSE
				)
				
				);
				
				$this->EE->dbforge->add_field($fields);
				$this->EE->dbforge->add_key('id', TRUE);
				$this->EE->dbforge->create_table('exp_state_rates');

Open in new window

0
Comment
Question by:rgranlund
2 Comments
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 40575851
You are spelling 'auto_incriment' wrong.  Should be 'auto_increment'.  http://dev.mysql.com/doc/refman/5.0/en/example-auto-increment.html  Auto_increment in MySQL can only be used on the primary key.

'unsigned' only applies to numeric data, not 'varchar'.  http://dev.mysql.com/doc/refman/5.0/en/numeric-type-overview.html
0
 
LVL 7

Author Comment

by:rgranlund
ID: 40575861
oh man... I just had a duhhhh moment! It's cause I'm wearing new glasses.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

791 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question