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 6643725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:05:02+00:00 2026-05-26T00:05:02+00:00

This might be a noob question but I can’t find anything wrong with my

  • 0

This might be a noob question but I can’t find anything wrong with my code and I’m still getting mysql errors.

I am using this code to submit a form to a MYSQL database ->

    if($forename == '' || $surname == '' || $email == '' || $address1 == '' || $address2 == '' || $terms == ''){
        $_SESSION['status'] = 'error';
    } else {
            $sql = "INSERT INTO dbEntry ('forename','surname','email','address1','address2','terms')
            VALUES ('$forename','$surname','$email','$address1','$address2','$terms')" or die(mysql_error());
            $results = mysql_query($sql);

            if ($results) { echo "Details added."; }

            //if (mysql_error()) echo mysql_error();

        $_SESSION['status'] = 'success';
    }

//Print query for debugging ->
echo $sql;

But it’s throwing this error ->

INSERT INTO dbEntry (‘forename’,’surname’,’email’,’address1′,’address2′,’terms’) VALUES (‘asd’,’asd’,’asd@asd.com’,’asd’,’as’,’NULL’)
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 ”forename’,’surname’,’email’,’address1′,’address2′,’terms’) VALUES (‘asd’,’as’ at line 1

I have created a table to this structure ->

id INT(10) NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id),
forename VARCHAR(32) NOT NULL,
surname VARCHAR(32) NOT NULL,
email VARCHAR(64) NOT NULL,
address1 VARCHAR(64) NOT NULL,
address2 VARCHAR(64) NOT NULL,
terms TINYINT(1)

I can’t see any syntax errors, where am I going wrong? Apologies if I included too much info.

Cheers

  • 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-05-26T00:05:02+00:00Added an answer on May 26, 2026 at 12:05 am

    Do not surround the column names in single quotes in the insert column list.

    INSERT INTO dbEntry (forename,surname,email,address1,address2,terms) VALUES ('asd','asd','asd@asd.com','asd','as','NULL') 
    

    If your column names happen to be MySQL reserved keywords, or include spaces, hyphens, or other special but valid characters, you must surround them in backquotes:

    INSERT INTO tbl (`desc`, `space table`, `etc`)...
    

    As a hint, when MySQL prints a syntax error, 99% of the time the error occurs at the exact character where the right syntax to use near " opening quote begins.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This might be a noob question, but can't find an answer anywhere. I have
This might sound like a noob question, but here it goes anyway. Can BlackBerry
Ok, this might be a very noob question, but I find that PHP Documentation
This might sound like a little bit of a crazy question, but how can
This might be a noob question. but I'm really torned between adding documents to
This might sound like a noob question but this is the first time I'm
Apologies for this basic question, but I am noob stumped. The below code works
This might be a noob question but i've been fiddling with it for hours
Hi there this might me a very noob question but I'm stuck, and I'm
This might be a noob question, but I'm wondering if there's a way to

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.