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
https://forums.phpfreaks.com/topic/265956-empty-variable/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.