Click to See Complete Forum and Search --> : Anyone see the error in this script?


mkb116
02-07-2008, 02:47 AM
Ok the script validates fine. It shows the errors no problem, but when its comes back with no errors, I get this error "SQL/DB 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 ')' at line 61] AND it does print the success message but doesn't insert the info in the database. Any ideas?


function submitreview ()
{
$this->_load_class ( 'form_validation' );
$msg = 'info|' . $this->functions->Lang ( 'inf_register' );
if ( array_key_exists ( '_submit_check', $_POST ) )
{
extract ( $_POST );

if ( ! empty ( $url ) ) {//do we have a spam bot?
$msg = 'error|' . $this->functions->Lang ( 'spam_bot' );
}
else {
$this->form_validation->add_field ( 'shopname', 'required', $this->functions->Lang ( 'required' ) );
$this->form_validation->add_field ( 'shopname', 'alpha_numeric', $this->functions->Lang ( 'characters' ) );

$this->form_validation->add_field ( 'shopaddress', 'required', $this->functions->Lang ( 'required' ) );
$this->form_validation->add_field ( 'shopaddress', 'alpha_numeric', $this->functions->Lang ( 'characters' ) );

$this->form_validation->add_field ( 'shopcity', 'required', $this->functions->Lang ( 'required' ) );
$this->form_validation->add_field ( 'shopcity', 'alpha_numeric', $this->functions->Lang ( 'characters' ) );

$this->form_validation->add_field ( 'shopstate', 'required', $this->functions->Lang ( 'required' ) );

$this->form_validation->add_field ( 'shopzip', 'required', $this->functions->Lang ( 'required' ) );
$this->form_validation->add_field ( 'shopzip', 'alpha_numeric', $this->functions->Lang ( 'characters' ) );

$this->form_validation->add_field ( 'shopsite', 'acceptable_characters', $this->functions->Lang ( 'characters' ) );

$this->form_validation->add_field ( 'shopphone', 'alpha_numeric', $this->functions->Lang ( 'characters' ) );

$this->form_validation->add_field ( 'shopspecialty', 'required', $this->functions->Lang ( 'required' ) );

$this->form_validation->add_field ( 'shopcontactperson', 'alpha_numeric', $this->functions->Lang ( 'characters' ) );

$this->form_validation->add_field ( 'custserviced', 'acceptable_characters', $this->functions->Lang ( 'characters' ) );

$this->form_validation->add_field ( 'thread', 'acceptable_characters', $this->functions->Lang ( 'characters' ) );

$this->form_validation->add_field ( 'custforumusername', 'acceptable_characters', $this->functions->Lang ( 'characters' ) );

$this->form_validation->add_field ( 'professionalism', 'required', $this->functions->Lang ( 'required' ) );

$this->form_validation->add_field ( 'turnaround', 'required', $this->functions->Lang ( 'required' ) );

$this->form_validation->add_field ( 'courtesy', 'required', $this->functions->Lang ( 'required' ) );

$this->form_validation->add_field ( 'quality', 'required', $this->functions->Lang ( 'required' ) );

$this->form_validation->add_field ( 'cleanliness', 'required', $this->functions->Lang ( 'required' ) );

$this->form_validation->add_field ( 'customerservice', 'required', $this->functions->Lang ( 'required' ) );

$this->form_validation->add_field ( 'goback', 'required', $this->functions->Lang ( 'required' ) );

$this->form_validation->add_field ( 'pricing', 'required', $this->functions->Lang ( 'required' ) );

$this->form_validation->add_field ( 'rating', 'required', $this->functions->Lang ( 'required' ) );

$this->form_validation->add_field ( 'comments', 'acceptable_characters', $this->functions->Lang ( 'characters' ) );

$this->form_validation->add_field ( 'pictures', 'acceptable_characters', $this->functions->Lang ( 'characters' ) );

if ( $this->form_validation->execute () )
{
$query = $this->db->query
(
"INSERT INTO
" . DBPREFIX . " table1
(
`shopname`,
`shopaddress`,
`shopcity`,
`shopstate`,
`shopzip`,
`shopphone`,
`shopsite`,
`shopspecialty`,
`shopcontactperson`,
`custemail`,
`custserviced`,
`thread`,
`custforumusername`,
`professionalism`,
`turnaround`,
`courtesy`,
`quality`,
`cleanliness`,
`customerservice`,
`goback`,
`pricing`,
`comments`,
`pictures`,
`rating`,
`ip`,
`referred`,
`time`
)
VALUES
(
" . $this->db->qstr ( $shopname ) . ",
" . $this->db->qstr ( $shopaddress ) . ",
" . $this->db->qstr ( $shopcity ) . ",
" . $this->db->qstr ( $shopstate ) . ",
" . $this->db->qstr ( $shopzip ) . ",
" . $this->db->qstr ( $shopphone ) . ",
" . $this->db->qstr ( $shopsite ) . ",
" . $this->db->qstr ( $shopspecialty ) . ",
" . $this->db->qstr ( $shopcontactperson ) . ",
" . $this->db->qstr ( $custemail ) . ",
" . $this->db->qstr ( $custserviced ) . ",
" . $this->db->qstr ( $thread ) . ",
" . $this->db->qstr ( $custforumusername ) . ",
" . $this->db->qstr ( $professionalism ) . ",
" . $this->db->qstr ( $turnaround ) . ",
" . $this->db->qstr ( $courtesy ) . ",
" . $this->db->qstr ( $quality ) . ",
" . $this->db->qstr ( $cleanliness ) . ",
" . $this->db->qstr ( $customerservice ) . ",
" . $this->db->qstr ( $goback ) . ",
" . $this->db->qstr ( $pricing ) . ",
" . $this->db->qstr ( $comments ) . ",
" . $this->db->qstr ( $pictures ) . ",
" . $this->db->qstr ( $rating ) . ",
" . $this->db->qstr ( $ip ) . ",
" . $this->db->qstr ( $referred ) . ",
" . $this->db->qstr ( $time ) . ",
)"
);

echo "<font color=#FFFFFF>Congratulations!</font><br>Your submission has been successfully received. You will also receive a confirmation email. If you discover any errors ANYWHERE please notify us using the contact link in the navigation bar.";

scragar
02-07-2008, 05:22 AM
it ends in ,) remove that offending comma.


function submitreview ()
{
$this->_load_class ( 'form_validation' );
$msg = 'info|' . $this->functions->Lang ( 'inf_register' );
if ( array_key_exists ( '_submit_check', $_POST ) )
{
extract ( $_POST );

if ( ! empty ( $url ) ) {//do we have a spam bot?
$msg = 'error|' . $this->functions->Lang ( 'spam_bot' );
}
else {
$this->form_validation->add_field ( 'shopname', 'required', $this->functions->Lang ( 'required' ) );
$this->form_validation->add_field ( 'shopname', 'alpha_numeric', $this->functions->Lang ( 'characters' ) );

$this->form_validation->add_field ( 'shopaddress', 'required', $this->functions->Lang ( 'required' ) );
$this->form_validation->add_field ( 'shopaddress', 'alpha_numeric', $this->functions->Lang ( 'characters' ) );

$this->form_validation->add_field ( 'shopcity', 'required', $this->functions->Lang ( 'required' ) );
$this->form_validation->add_field ( 'shopcity', 'alpha_numeric', $this->functions->Lang ( 'characters' ) );

$this->form_validation->add_field ( 'shopstate', 'required', $this->functions->Lang ( 'required' ) );

$this->form_validation->add_field ( 'shopzip', 'required', $this->functions->Lang ( 'required' ) );
$this->form_validation->add_field ( 'shopzip', 'alpha_numeric', $this->functions->Lang ( 'characters' ) );

$this->form_validation->add_field ( 'shopsite', 'acceptable_characters', $this->functions->Lang ( 'characters' ) );

$this->form_validation->add_field ( 'shopphone', 'alpha_numeric', $this->functions->Lang ( 'characters' ) );

$this->form_validation->add_field ( 'shopspecialty', 'required', $this->functions->Lang ( 'required' ) );

$this->form_validation->add_field ( 'shopcontactperson', 'alpha_numeric', $this->functions->Lang ( 'characters' ) );

$this->form_validation->add_field ( 'custserviced', 'acceptable_characters', $this->functions->Lang ( 'characters' ) );

$this->form_validation->add_field ( 'thread', 'acceptable_characters', $this->functions->Lang ( 'characters' ) );

$this->form_validation->add_field ( 'custforumusername', 'acceptable_characters', $this->functions->Lang ( 'characters' ) );

$this->form_validation->add_field ( 'professionalism', 'required', $this->functions->Lang ( 'required' ) );

$this->form_validation->add_field ( 'turnaround', 'required', $this->functions->Lang ( 'required' ) );

$this->form_validation->add_field ( 'courtesy', 'required', $this->functions->Lang ( 'required' ) );

$this->form_validation->add_field ( 'quality', 'required', $this->functions->Lang ( 'required' ) );

$this->form_validation->add_field ( 'cleanliness', 'required', $this->functions->Lang ( 'required' ) );

$this->form_validation->add_field ( 'customerservice', 'required', $this->functions->Lang ( 'required' ) );

$this->form_validation->add_field ( 'goback', 'required', $this->functions->Lang ( 'required' ) );

$this->form_validation->add_field ( 'pricing', 'required', $this->functions->Lang ( 'required' ) );

$this->form_validation->add_field ( 'rating', 'required', $this->functions->Lang ( 'required' ) );

$this->form_validation->add_field ( 'comments', 'acceptable_characters', $this->functions->Lang ( 'characters' ) );

$this->form_validation->add_field ( 'pictures', 'acceptable_characters', $this->functions->Lang ( 'characters' ) );

if ( $this->form_validation->execute () )
{
$query = $this->db->query
(
"INSERT INTO
" . DBPREFIX . " table1
(
`shopname`,
`shopaddress`,
`shopcity`,
`shopstate`,
`shopzip`,
`shopphone`,
`shopsite`,
`shopspecialty`,
`shopcontactperson`,
`custemail`,
`custserviced`,
`thread`,
`custforumusername`,
`professionalism`,
`turnaround`,
`courtesy`,
`quality`,
`cleanliness`,
`customerservice`,
`goback`,
`pricing`,
`comments`,
`pictures`,
`rating`,
`ip`,
`referred`,
`time`
)
VALUES
(
" . $this->db->qstr ( $shopname ) . ",
" . $this->db->qstr ( $shopaddress ) . ",
" . $this->db->qstr ( $shopcity ) . ",
" . $this->db->qstr ( $shopstate ) . ",
" . $this->db->qstr ( $shopzip ) . ",
" . $this->db->qstr ( $shopphone ) . ",
" . $this->db->qstr ( $shopsite ) . ",
" . $this->db->qstr ( $shopspecialty ) . ",
" . $this->db->qstr ( $shopcontactperson ) . ",
" . $this->db->qstr ( $custemail ) . ",
" . $this->db->qstr ( $custserviced ) . ",
" . $this->db->qstr ( $thread ) . ",
" . $this->db->qstr ( $custforumusername ) . ",
" . $this->db->qstr ( $professionalism ) . ",
" . $this->db->qstr ( $turnaround ) . ",
" . $this->db->qstr ( $courtesy ) . ",
" . $this->db->qstr ( $quality ) . ",
" . $this->db->qstr ( $cleanliness ) . ",
" . $this->db->qstr ( $customerservice ) . ",
" . $this->db->qstr ( $goback ) . ",
" . $this->db->qstr ( $pricing ) . ",
" . $this->db->qstr ( $comments ) . ",
" . $this->db->qstr ( $pictures ) . ",
" . $this->db->qstr ( $rating ) . ",
" . $this->db->qstr ( $ip ) . ",
" . $this->db->qstr ( $referred ) . ",
" . $this->db->qstr ( $time ) . "
)"
);

echo "<font color=#FFFFFF>Congratulations!</font><br>Your submission has been successfully received. You will also receive a confirmation email. If you discover any errors ANYWHERE please notify us using the contact link in the navigation bar.";