Jump to content

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/243106-array-problem-please-help/
Share on other sites

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.

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'"];

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!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.