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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:47:41+00:00 2026-06-13T18:47:41+00:00

At the moment I am running an update query which is working, however it

  • 0

At the moment I am running an update query which is working, however it allows null values to be inserted which I don’t want.

mysql_query('UPDATE community_table SET 
age = "'.$age.'", 
gender = "'.$gender.'", 
pregnant = "'.$pregnant.'", 
diet = "'.$diet.'",
smoker = "'.$smoker.'",
alcohol = "'.$alcohol.'",
exercise = "'.$exercise.'",
bmi = "'.$bmi.'",
sleeping = "'.$sleeping.'",
stress = "'.$stress.'", 
education = "'.$education.'"
WHERE username = "' . $_SESSION['user'] . '" ');

I tried this query which seems to prevent null values being entered, however it also prevents values being entered when the variables are not null.

age = "'.$age.'", 
gender = "'.$gender.'", 
pregnant = "'.$pregnant.'", 
diet = "'.$diet.'",
smoker = "'.$smoker.'",
alcohol = "'.$alcohol.'",
exercise = "'.$exercise.'",
bmi = "'.$bmi.'",
sleeping = "'.$sleeping.'",
stress = "'.$stress.'", 
education = "'.$education.'"

WHERE age IS NOT NULL,
gender     IS NOT NULL,
pregnant   IS NOT NULL,
diet       IS NOT NULL,
smoker     IS NOT NULL, 
alcohol    IS NOT NULL,
exercise   IS NOT NULL,
bmi        IS NOT NULL,
sleeping   IS NOT NULL,
stress     IS NOT NULL,
education  IS NOT NULL and where
username = "' . $_SESSION['user'] . '" ');

Is there something wrong with the above query, or do I perhaps have a null value in my input?

Thanks.

  • 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-13T18:47:42+00:00Added an answer on June 13, 2026 at 6:47 pm

    You can prevent empty string from being sent from your script or try this

    UPDATE community_table SET
        education = IFNULL($education, education) -- if null, maintain previous value
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently working on a web app/game using C# and ASP.NET(3.5). However, I'm running
I'm running an algorithm at the moment that is very heavy but extremely parallel.
I'm running into a bit of dilemma at the moment in that I need
at the moment I have my jQuery plugin running it's logic in if statments.
I am running into lots of problems with Unicode at the moment. As I
I've an issue at the moment where we are running a CMS within a
I'm trying to get an odata demo up and running at the moment, but
We have an ASP.NET page running on .NET Framework 4.0. At the moment we
I have 2 servers setup at the moment. One is a web server running
At the moment, I have a wordpress-based site at http://sub.mydomain.com , running for 2

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.