Jump to content

empty variable


Guest

Recommended Posts

Hy guys. I wonder if anybody knows a solution to this...

 

I have form with some selection/option fields. And as first option I set

 

<option value='NE' style='display:none;'></option>

 

So that when form is opened no option is selected. Or it would appear so...

 

Then I post this form to php for processing and insertion in to database. But I want to do one IF check first. SO that when this first option is selected variable does not get declared/set and it appears as empty '' in my sql string.

 

Something like this:

 

if($_POST['poznanstvopriporocilo'] == 'NE') {
$poznanstvopriporocilo = "";
}
else {
$poznanstvopriporocilo = $_POST['poznanstvopriporocilo'];
}

 

But as it is now it does not work. I still get an error when query is run. I believe because variable still comes out as something like 'NE' or ' ' or ... something wrong which breaks my mysqli_query and returns error.

 

If I choose some options from selection drop-down, then it works perfectly. So problem must be with this not-so-much-or-wrongly-emptied-string I am trying to get.

 

I also tried unset($poznanstvopriporocilo);

 

Same results. Any idea?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.