Solved

Query Syntax

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
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…

930 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

9 Experts available now in Live!

Get 1:1 Help Now