Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8217955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:37:23+00:00 2026-06-07T12:37:23+00:00

I am having a problem inserting values from a selection of dropdown boxes into

  • 0

I am having a problem inserting values from a selection of dropdown boxes into MYSQL database.

I think I have narrowed it down to a problem in the .sql file. I have sat for hours trying to figure this out but I am a complete beginner to all this and may be missing something very small.

mysql_error() shows:

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 1

SQL file:

-- phpMyAdmin SQL Dump
-- version 3.3.9
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Jun 27, 2012 at 10:06 PM
-- Server version: 5.5.8
-- PHP Version: 5.3.5

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

--
-- Database: `chilli`
--
DROP DATABASE IF EXISTS `chilli`;
CREATE DATABASE `chilli` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
USE `chilli`;

-- --------------------------------------------------------

--
-- Table structure for table `survey`
--

DROP TABLE IF EXISTS `survey`;
CREATE TABLE IF NOT EXISTS `survey` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `username` varchar(50) NOT NULL,
  `videos` varchar(50) NOT NULL,
  `scoville` varchar(50) NOT NULL,
  `extract` varchar(50) NOT NULL,
  `onions` varchar(50) NOT NULL,
  `retail` varchar(50) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;

--
-- Dumping data for table `survey`
--

INSERT INTO `survey` (`id`, `username`, `videos`, `scoville`, `extract`, `onions`, `retail`) VALUES
(1, 'sean', 'Yes', '0-200,000 SHU', 'Yes', 'No', 'No');


-- --------------------------------------------------------



--

-- Table structure for table `orders`

--



DROP TABLE IF EXISTS `orders`;

CREATE TABLE IF NOT EXISTS `orders` (

  `id` int(11) NOT NULL AUTO_INCREMENT,
  `address` varchar(50) NOT NULL,

  `mild` varchar(50) NOT NULL,

  `medium` varchar(50) NOT NULL,

  `hot` varchar(50) NOT NULL,

  `v_hot` varchar(50) NOT NULL,

  PRIMARY KEY (`id`)

) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;



--

-- Dumping data for table `orders`

--



INSERT INTO `orders` (`id`, `address`, `mild`, `medium`, `hot`, `v_hot`) VALUES

(1, 'Fairman Place', 'Ancho', 'Chipotle', 'Shabu Shabu', 'Infinity Chilli');

PHP code:

<?php require_once('Connections/localhost.php'); ?>

<?php


$add = $_POST['address'];
$mild = $_POST['mild'];
$medi = $_POST['medium'];
$hot = $_POST['hot'];
$v_hot = $_POST['v_hot'];


mysql_select_db($database_localhost,$localhost);

$q2 = "INSERT INTO orders VALUES (NULL, '$add', $mild', '$medi', '$hot', '$v_hot')";
$r2 = mysql_query($q2,$localhost);

if (mysql_affected_rows($localhost) == 1) {
    echo '<script type="text/javascript" language="javascript">
    alert("Your order has been placed! Thank You.");
    history.back();</script>';
    }

    else {
        //query failure
    echo mysql_error();
    echo '<script type="text/javascript" language="javascript">
    alert("The order could not be completed due to a system error");
    history.back();</script>';  
    }

mysql_close($localhost);


?>

Please Note

As you can see from the sql file there is two tables (survey & orders). The first table(survey) works fine, with close to identical PHP code. It adds records to table with no problem. But I can’t seem to add values to the second table(orders).

From what I see from other peoples code on this site, my code may seem a little unorthodox so feel free to mention any tips to tidy the code.

This topic has been covered a few times from what I can see but I still can’t seem to find a resolution by emulating the answers given.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T12:37:25+00:00Added an answer on June 7, 2026 at 12:37 pm

    You’re missing a single quote in your query:

    $q2 = "INSERT INTO orders VALUES (NULL, '$add', $mild', '$medi', '$hot', '$v_hot')";
                                                   ^
                                                   Right here
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having a very strange problem inserting values into my mysql database, using
I'm having a strange problem in that I have php inserting text into a
I am having problem with inserting string values (user_name, password) into a table, named
I have been running into problems inserting values into a table after having a
Hey I'm having a problem with inserting an ICanHaz.js template into a jquery mobile
I'm having a bit of trouble inserting into a sqlite3 database with pdo. You'll
I'm having problems doing the Database example from PhoneGap. http://docs.phonegap.com/phonegap_storage_storage.md.html#openDatabase The Problem is, when
I am having a problem with inserting new data into MS Access 2007 file.
I am having problems when inserting data into a sqlite table, I have read
I am having a problem with inserting a username and password in a login

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.