Solved

Query Syntax

Posted on 2015-01-28
2
41 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 82

Accepted Solution

by:
Dave Baldwin earned 500 total points
Comment Utility
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
Comment Utility
oh man... I just had a duhhhh moment! It's cause I'm wearing new glasses.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now