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

  • Home
  • SEARCH
  • 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 8033499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:43:02+00:00 2026-06-05T01:43:02+00:00

So I have a database setup in MySQL with three columns. The first column

  • 0

So I have a database setup in MySQL with three columns. The first column is ‘idnum’ that auto increments the users id numbers. The second and third are first and last names respectfully. My problem is when I go to send the the names to the DB via a query string in my PHP file, I get a couple different errors back…

When I send the query:

$sql = "insert into namesdb values('NULL', 'firstname', 'lastname')";
$result = $db->query($sql);

I get back this error: “Incorrect integer value: ‘NULL’ for column ‘idnum’ at row 1.” Because column 1 is an INT type.

But then when I send this query:

$sql = "insert into namesdb values(".NULL.", 'firstname', 'lastname')";
$result = $db->query($sql);

I get back a syntax error…

Any idea on what the heck I’m doing wrong here??

Thank you for any help!

  • 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-05T01:43:05+00:00Added an answer on June 5, 2026 at 1:43 am

    It should be:

    $sql = "insert into namesdb values(NULL, 'firstname', 'lastname')";
    $result = $db->query($sql);
    

    'NULL' is a string of "NULL".

    Though another option (the one I would go with) is to list the columns explicitly:

    INSERT INTO namesdb (firstname, lastname) VALUES ('firstname', 'lastname')
    

    I prefer listing the columns because it is more future proof, and it’s easier to see what’s going on. Imagine if columns are rearranged, added, or removed in the future. Suddenly fixing your queries is going to be a massive pain if you have to remove the 6th unnamed parameter everywhere (for example).

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

Sidebar

Related Questions

I have a database that stores images in a MySQL BLOB field. I setup
I have setup a database view. When users import the data from the view
I have a tool that is setup to query our Clearquest Database to return
I have a mySQL database that tracks our projects and drives our website's display
So I have a database that is setup sort of like this (simplified, and
the deal is this: I have a MySQL database that is built in this
My project setup is like this Server side I have webserver with PHP,MySQL database
I have a mysql database with 21 tables, all have relationships setup, I made
I have a MySQL 5 database that is updated every 5 minutes from a
I have a few tables in a MySQL database similar to this setup: major

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.