I want to remove all spaces and replace them with -'s from a posted row in mysql database after it is submitted to the form...so that I can use it in a URL without getting %20%, this is what I have... $q_title_ = str_replace(" ", "-", "{$_POST['q_title']}"); $directory = "../question/{$_POST['category']}/$q_title_/"; mkdir("$directory", 0777); any idea what I'm doing wrong?
What sunnyverma1984 suggested won't work, it'll cause a syntax error. Your code, other than its formatting, seems okay. Can you be more specific as to what doesn't work exactly? Do you get some error? A blank page? Unexpected result of some kind? A dinasure attack you? Its really hard to say what's wrong when you don't say what's not working.
try this: $q_title_ = str_replace(" ", "-", $_POST['q_title']); $directory = "../question/".$_POST['category']."/".$q_title_."/"; mkdir($directory, 0777); Code (markup):