Creating a database for a single page
Permalink
I am having trouble insert items in a table from my single page controller.
It seems all the values are posting correctly.
But I get an "Access or Syntax" violation.
An exception occurred while executing 'INSERT INTO quickEvents (id, name, short, long, dates) VALUES (?, ?, ?, ?, ?)' with params [1, "empty", "empty", "empty", "empty"]: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'long, dates) VALUES ('1', 'empty', 'empty', 'empty', 'empty')' at line 1
My code is simply:
It gets called by the single page form submit:
It seems all the values are posting correctly.
But I get an "Access or Syntax" violation.
An exception occurred while executing 'INSERT INTO quickEvents (id, name, short, long, dates) VALUES (?, ?, ?, ?, ?)' with params [1, "empty", "empty", "empty", "empty"]: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'long, dates) VALUES ('1', 'empty', 'empty', 'empty', 'empty')' at line 1
My code is simply:
public function new_event() { if ( $this->token->validate("new_event") ) { if ( Request::isPost() ) { $receive = array( 'id','name','short','long','dates' ); $data = array(); foreach ( $receive as $key ) { $post = $this->post($key); !$post ? $post = 'empty' : $post = $post; $data[$key] = $post; } $db = Database::connection(); $query = "INSERT INTO quickEvents ( id,
Viewing 15 lines of 31 lines. View entire code block.
It gets called by the single page form submit:
<form class="quick-events-add-event" method="post" action="<?=$this->action('new_event')?>">