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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:44:45+00:00 2026-05-31T18:44:45+00:00

$query=INSERT INTO subscriber (RandomCode,Email,CreateDate,UpdateDate <?if ($num!=0) echo ‘,’.$string; ?> ) VALUES (?,?,?,?,CURDATE(),”,<? if ($num!=0)

  • 0
$query="INSERT INTO subscriber (RandomCode,Email,CreateDate,UpdateDate <?if ($num!=0) echo ','.$string; ?> ) VALUES (?,?,?,?,CURDATE(),'',<? if ($num!=0) echo ','.$stringResult; ?>)";
echo $query;

If i add something conditional in the sql statement , it will not check or trigger the php function.

   if (!isset($set['Attribute']))
{$set['Attribute']=NULL;} <=======This statement  to check if there is no value posted
$stringResult=$stringResult.$_POST[$set['Attribute']].",";}}
$stringResult = substr($stringResult, 0, -1);
echo $stringResult;

Also, if a result is a null value posted, how can i set it so that it can be view in stringResult as ” ? I need to put it in my sql statement.

Thank you.

  • 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-31T18:44:46+00:00Added an answer on May 31, 2026 at 6:44 pm
    $query="INSERT INTO subscriber (RandomCode,Email,CreateDate,UpdateDate <?if ($num!=0) echo ','.$string; ?> ) VALUES (?,?,?,?,CURDATE(),'',<? if ($num!=0) echo ','.$stringResult; ?>)";
    

    This is broken; you don’t echo to add to a string, you need to concatenate it together. Here’s how:

    $query="INSERT INTO subscriber (RandomCode,Email,CreateDate,UpdateDate";
    
    if ($num!=0)
    {
        $query .= ',' . $string; 
    }
    
    $query .= ") VALUES (?,?,?,?,CURDATE(),'',"
    
    if ($num!=0)
    {
        $query .= ','.$stringResult;
    }
    
    $query .= ")";
    

    When you are guilding a string and need to stop and make a decision, like “is this zero? then do this, now continue on.”, you need to end the string, concatenate a string into it if need be, and then concatenate the rest of the string onto the end. Continue ending the string and concatenating parts on until you are done.

    If you are adding a null value to a string, it’s the same as adding an empty string – ''.

    $string "mystring" . NULL . "morestring";  //result is "mystringmorestring"
    $string "mystring" . "" . "morestring";  //result is "mystringmorestring"
    

    The resulting string is exactly the same. While NULL !== “” (meaning NULL and “” are not identical because they are not the same type), as far as the resulting string goes, it’s the same.

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

Sidebar

Related Questions

Whats wrong with insert query. $result = $conn->query(insert into user (fullname,username,email,passwd) values ('.$data['fullname'].','.$data['username'].','.$data['email'].','.$data['fullname'].') );
Here is the query: INSERT INTO `users` (username, password, email) VALUES ('testu', 'testp', 'teste')
I have the following query: INSERT INTO table (a, b, c) VALUES (NOW(), NOW()
im trying to insert this query with mysql_query INSERT INTO um_group_rights (`um_group_id`,`cms_usecase_id`,`um_right_id`) VALUES (2,1,1)
I have some problem whith such mysql_query INSERT INTO table VALUES ('', CURDATE()-1) why
I'm using the following query: INSERT INTO role (name, created) VALUES ('Content Coordinator', GETDATE()),
Here's the query: INSERT INTO jobemails (jobid, to, subject, message, headers, datesent) VALUES ('340',
I've the following query: INSERT INTO table ( memberid, field1, field2, field3 ) VALUES
I am running this sort of query: insert into mytable (id, col1, col2) values
I run this query insert into students (StudentName) values ('reza');insert into Records (RecordValue,StudentID) +

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.