doddsey_65 Posted February 21, 2011 Share Posted February 21, 2011 im wanting to change the sql in my query based on if a field is empty or not. if the field is empty then i dont want it to post anything, but if its not empty then it can post the content. heres what i have so far but it does post the content even if the field is empty. (!empty($password)) ? $pass_sql = "u_password = '$password'," : $pass_sql = null; $link->query("UPDATE ".TBL_PREFIX."users SET $pass_sql u_allow_user_pm = '".$_POST['allow_user_pm']."' WHERE u_username = '".$_POST['user_name']."'") or die(print_link_error()); how can i stop it from updating if the field is empty? Quote Link to comment https://forums.phpfreaks.com/topic/228375-form-sql-based-on-input-content/ Share on other sites More sharing options...
doddsey_65 Posted February 21, 2011 Author Share Posted February 21, 2011 never mind lol. i was hashing $password before building the if statement, which meant even though the field was empty it was hashing it, therefore it was no longer empty. Quote Link to comment https://forums.phpfreaks.com/topic/228375-form-sql-based-on-input-content/#findComment-1177559 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.