php form submission NULL

I need some code that will save a textfiled as "" not as null  i have tried
if ($_POST['Designer']='NULL'){$_POST['Desinger']= "";}

Open in new window

the syntax that it save is


   GetSQLValueString($_POST['Designer'], "text"),

Open in new window

LVL 2
beridiusAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Marco GasiFreelancerCommented:
Do you need to save something or you can skip save procedure? In this case you can do this

if (!empty($_POST['Designer'])){ //if value is not empty
   GetSQLValueString($_POST['Designer'], "text"), //then save
...
}

Cheers
0
beridiusAuthor Commented:
it just need to save as ' ' would be great
 
0
mars-vieCommented:
Just a comment:

This can not work -->
if ($_POST['Designer']='NULL')

Better
if ($_POST['Designer']=='NULL')
0
IT Pros Agree: AI and Machine Learning Key

We’d all like to think our company’s data is well protected, but when you ask IT professionals they admit the data probably is not as safe as it could be.

Marco GasiFreelancerCommented:
@mars-vie: good eye! I didn't saw that :-)

@beridius: then do this:

if (!empty($_POST['Designer'])){ //if value is not empty
  $_POST['Designer'] = '';
}

Cheers
0
StingRaYCommented:
empty returns TRUE even $_POST['Designer'] is equal to 0.

Try this:

if (!isset($_POST['Designer']) || is_null($_POST['Designer'])) {
    $designer = "";
} else {
    $designer = GetSQLValueString($_POST['Designer'], "text");
}

Open in new window

0
beridiusAuthor Commented:
none of them seemed to have worked
0
beridiusAuthor Commented:
  $updateSQL = sprintf("UPDATE tbl_client SET clientTitle=%s, Client_level=%s, ClientFirstname=%s, ClientSurname=%s, ClientAddress1=%s, ClientAddress2=%s, ClientAddress3=%s, ClientAddress4=%s, ClientAddress5=%s, ClientPostcode=%s,ClientCountry=%s, clientDeliveryTitle=%s, ClientDeliveryFirstname=%s, ClientDeliverySurname=%s, ClientDeliveryAddress1=%s, ClientDeliveryAddress2=%s, ClientDeliveryAddress3=%s, ClientDeliveryAddress4=%s, ClientDeliveryAddress5=%s, ClientDeliveryPostcode=%s, ClientDeliveryCountry=%s, ClientContact=%s, ClientSource=%s, ClientSource2=%s, ClientPhoneHome=%s, ClientPhoneWork=%s, ClientPhoneMobile=%s, ClientPhoneMobile2=%s, ClientFaxHome=%s, ClientEmail=%s, ClientMailingList=%s, ClientInfoSentNotes=%s, ClientProductNotes=%s, ClientOrderContact=%s , Designer=%s, ClientSamplesSent=%s, ClientShowroomVisitDate=%s, OpencartRef=%s, Clientfolderdir=%s, infosent1=%s, infosent2=%s, infosent3=%s, dateinfosent1=%s, dateinfosent2=%s, dateinfosent3=%s, ClientType=%s, ClientEmail2=%s WHERE clientID=%s", 
                       GetSQLValueString($_POST['clientTitle'], "text"),
					   GetSQLValueString($_POST['Client_level'], "text"),
                       GetSQLValueString($_POST['ClientFirstname'], "text"),
                       GetSQLValueString($_POST['ClientSurname'], "text"),
                       GetSQLValueString($_POST['ClientAddress1'], "text"),
                       GetSQLValueString($_POST['ClientAddress2'], "text"),
                       GetSQLValueString($_POST['ClientAddress3'], "text"),
                       GetSQLValueString($_POST['ClientAddress4'], "text"),
                       GetSQLValueString($_POST['ClientAddress5'], "text"),
                       GetSQLValueString($_POST['ClientPostcode'], "text"),
					   GetSQLValueString($_POST['ClientCountry'], "text"),
                       GetSQLValueString($_POST['clientDeliveryTitle'], "text"),
                       GetSQLValueString($_POST['ClientDeliveryFirstname'], "text"),
                       GetSQLValueString($_POST['ClientDeliverySurname'], "text"),
                       GetSQLValueString($_POST['ClientDeliveryAddress1'], "text"),
                       GetSQLValueString($_POST['ClientDeliveryAddress2'], "text"),
                       GetSQLValueString($_POST['ClientDeliveryAddress3'], "text"),
                       GetSQLValueString($_POST['ClientDeliveryAddress4'], "text"),
                       GetSQLValueString($_POST['ClientDeliveryAddress5'], "text"),
                       GetSQLValueString($_POST['ClientDeliveryPostcode'], "text"),
					   GetSQLValueString($_POST['ClientDeliveryCountry'], "text"),
                       GetSQLValueString($_POST['ClientContact'], "text"),
                       GetSQLValueString($_POST['ClientSource'], "int"),
                       GetSQLValueString($_POST['ClientSource2'], "text"),
                       GetSQLValueString($_POST['ClientPhoneHome'], "text"),
                       GetSQLValueString($_POST['ClientPhoneWork'], "text"),
                       GetSQLValueString($_POST['ClientPhoneMobile'], "text"),
                       GetSQLValueString($_POST['ClientPhoneMobile2'], "text"),
                       GetSQLValueString($_POST['ClientFaxHome'], "text"),
                       GetSQLValueString($_POST['ClientEmail'], "text"),
                       GetSQLValueString($mailinglist, "int"),
                       GetSQLValueString($_POST['ClientInfoSentNotes'], "text"),
                       GetSQLValueString($_POST['ClientProductNotes'], "text"),
                       GetSQLValueString($_POST['ClientOrderContact'], "text"),
					   GetSQLValueString($_POST['Designer'], "text"),
                       GetSQLValueString($_POST['ClientSamplesSent'], "text"),
                       GetSQLValueString($_POST['ClientShowroomVisitDate'], "text"),
					   GetSQLValueString($_POST['Clientfolderdir'], "text"),
					   GetSQLValueString($_POST['OpencartRef'], "text"),
					   GetSQLValueString($_POST['infosent1'], "text"),
					   GetSQLValueString($_POST['infosent2'], "text"),
					   GetSQLValueString($_POST['infosent3'], "text"),
					   GetSQLValueString($_POST['dateinfosent1'], "text"),
					   GetSQLValueString($_POST['dateinfosent2'], "text"),
					   GetSQLValueString($_POST['dateinfosent3'], "text"),
					   GetSQLValueString($_POST['ClientType'], "text"),
					   GetSQLValueString($_POST['ClientEmail2'], "text"),
					   GetSQLValueString($_POST['clientID'], "int"));

Open in new window

this is the update string
0
StingRaYCommented:
Try this:

(GetSQLValueString($_POST['Designer'], "text")=="NULL"?"":GetSQLValueString($_POST['Designer'], "text"))

Open in new window


For example:

  $updateSQL = sprintf("UPDATE tbl_client SET clientTitle=%s, Client_level=%s, ClientFirstname=%s, ClientSurname=%s, ClientAddress1=%s, ClientAddress2=%s, ClientAddress3=%s, ClientAddress4=%s, ClientAddress5=%s, ClientPostcode=%s,ClientCountry=%s, clientDeliveryTitle=%s, ClientDeliveryFirstname=%s, ClientDeliverySurname=%s, ClientDeliveryAddress1=%s, ClientDeliveryAddress2=%s, ClientDeliveryAddress3=%s, ClientDeliveryAddress4=%s, ClientDeliveryAddress5=%s, ClientDeliveryPostcode=%s, ClientDeliveryCountry=%s, ClientContact=%s, ClientSource=%s, ClientSource2=%s, ClientPhoneHome=%s, ClientPhoneWork=%s, ClientPhoneMobile=%s, ClientPhoneMobile2=%s, ClientFaxHome=%s, ClientEmail=%s, ClientMailingList=%s, ClientInfoSentNotes=%s, ClientProductNotes=%s, ClientOrderContact=%s , Designer=%s, ClientSamplesSent=%s, ClientShowroomVisitDate=%s, OpencartRef=%s, Clientfolderdir=%s, infosent1=%s, infosent2=%s, infosent3=%s, dateinfosent1=%s, dateinfosent2=%s, dateinfosent3=%s, ClientType=%s, ClientEmail2=%s WHERE clientID=%s", 
                       (GetSQLValueString($_POST['clientTitle'], "text")=="NULL"?"":GetSQLValueString($_POST['clientTitle'], "text")), // <-- This is an example
                                           GetSQLValueString($_POST['Client_level'], "text"),
                       GetSQLValueString($_POST['ClientFirstname'], "text"),
                       GetSQLValueString($_POST['ClientSurname'], "text"),
                       GetSQLValueString($_POST['ClientAddress1'], "text"),
                       GetSQLValueString($_POST['ClientAddress2'], "text"),
                       GetSQLValueString($_POST['ClientAddress3'], "text"),
                       GetSQLValueString($_POST['ClientAddress4'], "text"),
                       GetSQLValueString($_POST['ClientAddress5'], "text"),
                       GetSQLValueString($_POST['ClientPostcode'], "text"),
                                           GetSQLValueString($_POST['ClientCountry'], "text"),
                       GetSQLValueString($_POST['clientDeliveryTitle'], "text"),
                       GetSQLValueString($_POST['ClientDeliveryFirstname'], "text"),
                       GetSQLValueString($_POST['ClientDeliverySurname'], "text"),
                       GetSQLValueString($_POST['ClientDeliveryAddress1'], "text"),
                       GetSQLValueString($_POST['ClientDeliveryAddress2'], "text"),
                       GetSQLValueString($_POST['ClientDeliveryAddress3'], "text"),
                       GetSQLValueString($_POST['ClientDeliveryAddress4'], "text"),
                       GetSQLValueString($_POST['ClientDeliveryAddress5'], "text"),
                       GetSQLValueString($_POST['ClientDeliveryPostcode'], "text"),
                                           GetSQLValueString($_POST['ClientDeliveryCountry'], "text"),
                       GetSQLValueString($_POST['ClientContact'], "text"),
                       GetSQLValueString($_POST['ClientSource'], "int"),
                       GetSQLValueString($_POST['ClientSource2'], "text"),
                       GetSQLValueString($_POST['ClientPhoneHome'], "text"),
                       GetSQLValueString($_POST['ClientPhoneWork'], "text"),
                       GetSQLValueString($_POST['ClientPhoneMobile'], "text"),
                       GetSQLValueString($_POST['ClientPhoneMobile2'], "text"),
                       GetSQLValueString($_POST['ClientFaxHome'], "text"),
                       GetSQLValueString($_POST['ClientEmail'], "text"),
                       GetSQLValueString($mailinglist, "int"),
                       GetSQLValueString($_POST['ClientInfoSentNotes'], "text"),
                       GetSQLValueString($_POST['ClientProductNotes'], "text"),
                       GetSQLValueString($_POST['ClientOrderContact'], "text"),
                                           GetSQLValueString($_POST['Designer'], "text"),
                       GetSQLValueString($_POST['ClientSamplesSent'], "text"),
                       GetSQLValueString($_POST['ClientShowroomVisitDate'], "text"),
                                           GetSQLValueString($_POST['Clientfolderdir'], "text"),
                                           GetSQLValueString($_POST['OpencartRef'], "text"),
                                           GetSQLValueString($_POST['infosent1'], "text"),
                                           GetSQLValueString($_POST['infosent2'], "text"),
                                           GetSQLValueString($_POST['infosent3'], "text"),
                                           GetSQLValueString($_POST['dateinfosent1'], "text"),
                                           GetSQLValueString($_POST['dateinfosent2'], "text"),
                                           GetSQLValueString($_POST['dateinfosent3'], "text"),
                                           GetSQLValueString($_POST['ClientType'], "text"),
                                           GetSQLValueString($_POST['ClientEmail2'], "text"),
                                           GetSQLValueString($_POST['clientID'], "int"));

Open in new window

0
EMB01Commented:
Try echoing your var to see if it's creating the correct thing; GetSQLValueString may be changing the variable from empty to NULL or something.

echo $updateSQL;

You can try using this instead on that line:

Change:
GetSQLValueString($_POST['Designer'], "text"),

To this:
mysql_real_escape_string($_POST['Designer']),
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mars-vieCommented:
Are your mysql table settings correct?
Perhaps the field defaults to NULL instead of None?

M@RS
0
Ray PaseurCommented:
Designer or Desinger? These are not the same words.
0
Ray PaseurCommented:
Also, NULL is a PHP constant for an empty string.  However 'NULL' is a four-letter word.
0
Ray PaseurCommented:
One last comment then I will sign off on this question.  It appears that you are trying to learn PHP by reading Dreamweaver code, and that is a terrible way to learn the language.  It is like eating an apple pie and in the hope that by eating the pie you will somehow learn how to bake pies.  Seeing the finished product tells us little if anything about the thought processes that went into the creation.  And Dreamweaver contains some of the worst PHP code ever written.  Run, don't walk, to get this little book.  It is very readable and has excellent examples.  Now in its fourth printing, it has been a permanent part of my professional library since Version One.
http://www.sitepoint.com/books/phpmysql4/

Best of luck with your project, ~Ray
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MySQL Server

From novice to tech pro — start learning today.