Jezza Posted January 15, 2010 Share Posted January 15, 2010 <input type=hidden name="My Value" value="lol"> Later on... echo $_POST["My Value"]; The result is nothing, why doesn't this work and what can i do to get around this. It only does this when my POST variable doesn't have a space and i would LARGELY prefer this thing to be possible, how can i do this? Thanks for the help. Quote Link to comment https://forums.phpfreaks.com/topic/188552-post-variable-with-spaces-in-it/ Share on other sites More sharing options...
Zane Posted January 15, 2010 Share Posted January 15, 2010 Why do you need a space in the first place? Typically though, there shouldn't be a problem with spaces. But professionally, spaces are a no-no. Some questions to look over -------------------------------------------------------------- Are you sure you're form's method is set to POST? Are you sure you are POSTing to the correct page? Quote Link to comment https://forums.phpfreaks.com/topic/188552-post-variable-with-spaces-in-it/#findComment-995438 Share on other sites More sharing options...
Jezza Posted January 15, 2010 Author Share Posted January 15, 2010 I have a foreach() way of drawing a form for putting it in a database just say: $form=Array("Name"); it will display $val: <input type=text name="$val"> and whatnot Quote Link to comment https://forums.phpfreaks.com/topic/188552-post-variable-with-spaces-in-it/#findComment-995439 Share on other sites More sharing options...
Catfish Posted January 15, 2010 Share Posted January 15, 2010 if the key name is coming from a post variable, it may be possible the space is being url encoded to something like %20 i would assume. you could try using print_r($_POST); to see what is in the $_POST array. Quote Link to comment https://forums.phpfreaks.com/topic/188552-post-variable-with-spaces-in-it/#findComment-995441 Share on other sites More sharing options...
Zane Posted January 15, 2010 Share Posted January 15, 2010 I have a foreach() way of drawing a form for putting it in a database just say: $form=Array("Name"); it will display $val: and whatnot This doesn't make much sense. You'll have to show more code than that if you want some quality help. Quote Link to comment https://forums.phpfreaks.com/topic/188552-post-variable-with-spaces-in-it/#findComment-995445 Share on other sites More sharing options...
Catfish Posted January 15, 2010 Share Posted January 15, 2010 i just did a test on my web host and whitepace is being change to underscore character: _ so "Form Test" becomes "Form_Test" Quote Link to comment https://forums.phpfreaks.com/topic/188552-post-variable-with-spaces-in-it/#findComment-995446 Share on other sites More sharing options...
Jezza Posted January 15, 2010 Author Share Posted January 15, 2010 Aaah thanks a bunch, is there a way to stop it from whitespacing like that? Quote Link to comment https://forums.phpfreaks.com/topic/188552-post-variable-with-spaces-in-it/#findComment-995453 Share on other sites More sharing options...
trq Posted January 15, 2010 Share Posted January 15, 2010 Spaces are not aloud within an elements name attribute so no. Quote Link to comment https://forums.phpfreaks.com/topic/188552-post-variable-with-spaces-in-it/#findComment-995456 Share on other sites More sharing options...
salathe Posted January 15, 2010 Share Posted January 15, 2010 PHP will convert spaces and dots (and certain other characters) with underscore for $_POST and family (I believe the reasoning is to make a valid variable name). Either be aware of this automated conversion and code your receiving script with it in mind, or make sure the variable name is 'valid' (in the sense that it won't get changed) in the form. Quote Link to comment https://forums.phpfreaks.com/topic/188552-post-variable-with-spaces-in-it/#findComment-995458 Share on other sites More sharing options...
Jezza Posted January 15, 2010 Author Share Posted January 15, 2010 Nooooo, It's not fair, hehe, OK thanks Quote Link to comment https://forums.phpfreaks.com/topic/188552-post-variable-with-spaces-in-it/#findComment-995459 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.