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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:50:16+00:00 2026-06-04T17:50:16+00:00

I want to build query using two array 1 for column and another for

  • 0

I want to build query using two array 1 for column and another for value. I have 3 integer columns in first array for which I don’t want to store 0 as default so i want to set NULL, I want to check if any value entered for it, if not entered i want to set NULL for it .
But when i create query i cant see NULL, i just see null replaced by blank. Seems like PHP is stripping out the NULL word ?

$set_null = array("asst_phone","mailing_zip","other_zip");

    foreach($columns as $key=>$col){
    if(in_array($col,$set_null) && $values[$key] == ""){
       $val[$key] = NULL;
    }
    else    
       $val[$key] = "'".$values[$key]."'";
    }
    $query_vals = "";
    foreach($val as $qval){
      if($qval == "") $query_vals .= NULL;
        $query_vals .= $qval;
            }
    echo $query_vals;

It generates query like below

INSERT INTO zoho_contacts (`contactid`,`smownerid`,`contact_owner`,`lead_source`,`first_name`,`last_name`,`accountid`,`account_name`,`email`,`title`,`department`,`phone`,`home_phone`,`other_phone`,`fax`,`mobile`,`date_of_birth`,`assistant`,`asst_phone`,`reports_to`,`smcreatorid`,`created_by`,`modifiedby`,`modified_by`,`created_time`,`modified_time`,`mailing_street`,`other_street`,`mailing_city`,`other_city`,`mailing_state`,`other_state`,`mailing_zip`,`other_zip`,`mailing_country`,`other_country`,`description`,`email_opt_out`,`skype_id`,`salutation`,`add_to_quickbooks`,`secondary_email`) values ('418176000000052001','418176000000047003','','','','','418176000000047027','','','','','02164 25452132','','','','9798659821','','',,'','418176000000047003','','418176000000047003','','','','','','','','','',,,'','','','','','Mr.','','')

My mysql column structure

column properties = NULL => Yes, DEFAULT => NULL, right ??

  • 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-04T17:50:18+00:00Added an answer on June 4, 2026 at 5:50 pm

    Replace

    $val[$key] = NULL;
    

    with

    $val[$key] = 'NULL';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to build a Cocoa application using the Model-View-Controller design pattern. I have
I want to build a query that finds elements that have the autofocus-attribute and
I want to build GQL query to get an object using its numeric id.
I'm using SQLObject and want to programmatically build a query using the .q objects
I want to build the following pseudo query Select a From APDU a where
I want to build an animated transition between two view controllers in iOS, resembling
I want to build a shell script to execute the following two commands, but
I want to execute a mapreduce query, in erlang, that contains two map phases
We have a project using LINQ to SQL, for which I need to rewrite
I'm trying to build a query using HQL and OUTER JOIN s and just

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.