Newbrict Posted July 28, 2011 Share Posted July 28, 2011 I have a form which submits fields into an associative array like this: IP Addcress: <input id="IP Address" name="Saves['IP Address']" type="text"> Line: <input id="Line" name="Saves['Line']" type="text"> If I input "a" into Line and "b" into IP Address then submit my forum to a page that does this $Saves = $_GET['Saves']; print_r($Saves); echo $Saves['Line']; Array(['Line'] => a ['IP Address'] => b ) this is the print_r nothing was outputted for $_Saves['Line'] I really need to be able to output $Saves['Line'], no clue what the problem is. Quote Link to comment Share on other sites More sharing options...
WebStyles Posted July 28, 2011 Share Posted July 28, 2011 why do you have : after = in form elements? Quote Link to comment Share on other sites More sharing options...
Newbrict Posted July 28, 2011 Author Share Posted July 28, 2011 why do you have : after = in form elements? Sorry that was a typo when retyping it here, in the actual form I do not have those. I really need this problem solves, so if anyone has ideas just tell me.... Quote Link to comment Share on other sites More sharing options...
premiso Posted July 28, 2011 Share Posted July 28, 2011 Your problem lays within the single quotes: <input id=:"Line" name="Saves['Line']" type="text"> Should be: <input id="Line" name="Saves[Line]" type="text"> Same goes for the IP, remove the single quotes around IP Address in the html input tag, and your code will work. Quote Link to comment Share on other sites More sharing options...
WebStyles Posted July 28, 2011 Share Posted July 28, 2011 Just a note: to avoid such things, it's better to always copy/paste your code instead of typing it again, otherwise we're looking at things that don't really exist in your original code. Quote Link to comment Share on other sites More sharing options...
Newbrict Posted July 28, 2011 Author Share Posted July 28, 2011 So the problem is that print_r($Saves); outputs the array as Array( ['Line']=>a ['IP Address']=> b ) but echo $Saves['Line']; doesn't output anything Quote Link to comment Share on other sites More sharing options...
premiso Posted July 28, 2011 Share Posted July 28, 2011 So the problem is that If you are not going to read through the posts that solve your problem, why bother asking the question? Quote Link to comment Share on other sites More sharing options...
Newbrict Posted July 28, 2011 Author Share Posted July 28, 2011 So the problem is that If you are not going to read through the posts that solve your problem, why bother asking the question? What do you mean? I've read all the posts... Quote Link to comment Share on other sites More sharing options...
premiso Posted July 28, 2011 Share Posted July 28, 2011 Perhaps you should read it closer, it solves your problem: http://www.phpfreaks.com/forums/index.php?topic=339810.msg1601940#msg1601940 Notice how there are no more single quotes around the [Line] inside of the input box. Or if you want to leave your code the same: echo $Saves["'Line'"]; Quote Link to comment Share on other sites More sharing options...
Newbrict Posted July 28, 2011 Author Share Posted July 28, 2011 Perhaps you should read it closer, it solves your problem: http://www.phpfreaks.com/forums/index.php?topic=339810.msg1601940#msg1601940 Notice how there are no more single quotes around the [Line] inside of the input box. Yeah I thought you were only pointing out the colon Thank you very much! Quote Link to comment 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.