Jump to content

Array problem (Please help!!)


Newbrict

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!

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.