Guest Posted July 19, 2012 Share Posted July 19, 2012 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? Quote Link to comment https://forums.phpfreaks.com/topic/265956-empty-variable/ Share on other sites More sharing options...
xyph Posted July 19, 2012 Share Posted July 19, 2012 Why not output $_POST['poznanstvopriporocilo'] to see what it actually contains when you haven't selected anything? Quote Link to comment https://forums.phpfreaks.com/topic/265956-empty-variable/#findComment-1362831 Share on other sites More sharing options...
scootstah Posted July 19, 2012 Share Posted July 19, 2012 What is the error? Quote Link to comment https://forums.phpfreaks.com/topic/265956-empty-variable/#findComment-1362835 Share on other sites More sharing options...
Guest Posted July 20, 2012 Share Posted July 20, 2012 Hy. Error was in commas not in variable. And it's now resolved. Thank you for your interest. Quote Link to comment https://forums.phpfreaks.com/topic/265956-empty-variable/#findComment-1362999 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.